Closed Harardin closed 4 years ago
Thanks for contacting us, @Harardin. What's the exception you're getting? Please share a small repro project, so we can investigate this.
Thanks for contacting us, @Harardin. What's the exception you're getting? Please share a small repro project, so we can investigate this.
Here is the exception from the log which comes from this line of code var responce = await httpClient.PostJsonAsync<HttpResponseMessage>("https://localhost:44389/api/Registration", registrationForm);
:
System.Net.Http.HttpRequestException: Response status code does not indicate success: 302 (Found).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.AspNetCore.Components.HttpClientJsonExtensions.SendJsonAsync[T](HttpClient httpClient, HttpMethod method, String requestUri, Object content)
at CMS_Blazor.Pages.Dialogs.LoginDialog.RegistrationSentence.RegistrationAsync() in E:\SharpProjects\ASPProgects\CMS-Blazor\CMS-Blazor\Pages\Dialogs\LoginDialog\RegistrationSentence.razor:line 40
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.Rendering.Renderer.GetErrorHandledTask(Task taskToHandle)
Microsoft.AspNetCore.Components.Server.ComponentHub: Warning: Unhandled Server-Side exception
System.Net.Http.HttpRequestException: Response status code does not indicate success: 302 (Found).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.AspNetCore.Components.HttpClientJsonExtensions.SendJsonAsync[T](HttpClient httpClient, HttpMethod method, String requestUri, Object content)
at CMS_Blazor.Pages.Dialogs.LoginDialog.RegistrationSentence.RegistrationAsync() in E:\SharpProjects\ASPProgects\CMS-Blazor\CMS-Blazor\Pages\Dialogs\LoginDialog\RegistrationSentence.razor:line 40
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.Rendering.Renderer.GetErrorHandledTask(Task taskToHandle)
And a link on the project: project This is my small out of the main job project, I want to create a small CMS with ASP.NET and Blazor.
You need to look at Controllers folder there is a Registration Controller that takes a User data here is the link to a cs file: RegistrationController
And the Blazor page that makes a request link: Registration-Blazor-Page
I am having the exact same issue with a client-side Blazor app with an ASP.Net Core host. I'm using .Net Core 3.0 release version (client-side packages still preview 9.19465.2 of course).
Thanks for contacting us. This is going to be covered as part of a separate package for the final Blazor WASM release. There is no pending work for us here.
Thing is the issue can be handled by simple
try
andcatch
but as I read they are expensive for performance if used too much, so I prefer to handle all troubles manually if it is possible.So to the code sample:
The Controller Class:
Nothing special in it
And the blazor page code:
If I miss something and made a mistake somewhere please let me know and I close this issue as false alarmed.