Click here to Skip to main content
16,022,205 members

Comments by chocusatergus (Top 3 by date)

chocusatergus 22-Aug-24 12:03pm View    
Hi Richard. Thanks for the explanation ...much appreciated. As per your suggestion, I changed the code in the API so it returns BadRequest (400) when the registration fails. I rewrote my code as per your explanation above, but I the parsing of the response throws an exception

var problem = await response.Content.ReadFromJsonAsync<httpvalidationproblemdetails>();

I put a breakpoint and I see that the response variable catches the BadRequest(400) from the WEB Api but is throwing an exception
JsonException: The JSON value could not be converted to Microsoft.AspNetCore.Http.HttpValidationProblemDetails. Path: $ | LineNumber: 0 | BytePositionInLine: 74.
System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)

System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
System.Text.Json.Serialization.Converters.ObjectDefaultConverter<t>.OnTryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T value)
System.Text.Json.Serialization.JsonConverter<t>.TryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T value, out bool isPopulatedValue)
System.Text.Json.Serialization.JsonConverter<t>.ReadCore(ref Utf8JsonReader reader, JsonSerializerOptions options, ref ReadStack state)
System.Text.Json.Serialization.Metadata.JsonTypeInfo<t>.ContinueDeserialize(ref ReadBufferState bufferState, ref JsonReaderState jsonReaderState, ref ReadStack readStack)
System.Text.Json.Serialization.Metadata.JsonTypeInfo<t>.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken)
System.Threading.Tasks.ValueTask<tresult>.get_Result()
System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsyncCore<t>(HttpContent content, JsonSerializerOptions options, CancellationToken cancellationToken)
WebDevelopment.Controllers.RegistrationController.Registration(RegisterViewModel model) in RegistrationController.cs
+
var problem = await response.Content.ReadFromJsonAsync<httpvalidationproblemdetails>();
Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
System.Threading.Tasks.ValueTask<tresult>.get_Result()
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<invokeactionmethodasync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask<iactionresult> actionResultValueTask)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<invokenextactionfilterasync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<invokeinnerfilterasync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<invokenextresourcefilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<invokefilterpipelineasync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, b
chocusatergus 20-Apr-23 6:24am View    
Hi Afzaal:

Thanks for your response, but the problem still persist. I took away the duplicated Jquery script reference and I dragged and dropped the javascript files hence the paths are correct:




Notwithstanding this, the message still below pops up. When I open the dialog for the second time, then the debugger says that the Jquery pop up function isn't recognized.

lots:159

Uncaught TypeError: Cannot read properties of undefined (reading 'unobtrusive')
at HTMLDivElement.<anonymous> (Plots:159:37)
at HTMLDivElement.<anonymous> (jquery.min.js:2:85138)
at Function.each (jquery.min.js:2:2976)
at S.fn.init.each (jquery.min.js:2:1454)
at Object.<anonymous> (jquery.min.js:2:85120)
at c (jquery.min.js:2:28294)
at Object.fireWith [as resolveWith] (jquery.min.js:2:29039)
at l (jquery.min.js:2:79800)
at XMLHttpRequest.<anonymous> (jquery.min.js:2:82254)
(anonymous) @ Plots:159
(anonymous) @ jquery.min.js:2
each @ jquery.min.js:2
each @ jquery.min.js:2
(anonymous) @ jquery.min.js:2
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
l @ jquery.min.js:2
(anonymous) @ jquery.min.js:2
load (async)
send @ jquery.min.js:2
ajax @ jquery.min.js:2
S.fn.load @ jquery.min.js:2
OpenPopup @ Plots:156
(anonymous) @ Plots:152
dispatch @ jquery.min.js:2
v.handle @ jquery.min.js:2
Plots:165

Uncaught TypeError: $(...).html(...).dialog is not a function
at OpenPopup (Plots:165:26)
at HTMLAnchorElement.<anonymous> (Plots:152:25)
at HTMLDivElement.dispatch (jquery.min.js:2:43090)
at v.handle (jquery.min.js:2:41074)
OpenPopup @ Plots:165
(anonymous) @ Plots:152
dispatch @ jquery.min.js:2
v.handle @ jquery.min.js:2
Plots:159

Uncaught TypeError: Cannot read properties of undefined (reading 'unobtrusive')
at HTMLDivElement.<anonymous> (Plots:159:37)
at HTMLDivElement.<anonymous> (<anonymous>:2:85138)
at Function.each (<anonymous>:2:2976)
at S.fn.init.each (<anonymous>:2:1454)
at Object.<anonymous> (<anonymous>:2:85120)
at c (<anonymous>:2:28294)
at Object.fireWith [as resolveWith] (<anonymous>:2:29039)
at l (<anonymous>:2:79800)
at XMLHttpRequest.<anonymous> (<anonymous>:2:82254)
chocusatergus 18-Apr-23 13:16pm View    
Hi Nima:

Apologies for the late response. the sorting method below throw an exception

if (!string.IsNullOrEmpty(sortColumn) && !string.IsNullOrEmpty(sortColumnDirection))
{
query = query.OrderBy(sortColumn + " " + sortColumnDirection);
}

The exception is =.>No property of field 'asc exists in the type 'Progressreport' at Index 1

it seems that the code below isn't appropriate

var result = new DataTableResultViewModel<progressreport>
{
Draw = draw,
RecordsTotal = recordsTotal,
RecordsFiltered = filteredRecords,
Data = data
};