Hi, I fix my problem.
The problem was in Program.cs
I've put app.UseRouting();
before
app.UseAuthentication();
app.UseAuthorization();
After this change Logout works.
Thanks to your support.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, I Tried to implement an Authentication in my app all things works except LogOut.
I follow up this tutorial : https://codewithmukesh.com/blog/authentication-in-blazor-webassembly/#Authentication_State_Provider
When I click on Logout I received the message :
System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at FollowUpDash.Client.Services.AuthService.Logout() in C:\App\sbd\FollowUpDash\FollowUpDash\Client\Services\IAuthService.cs:line 36
at FollowUpDash.Client.Services.CustomStateProvider.Logout() in C:\App\sbd\FollowUpDash\FollowUpDash\Client\Services\CustomStateProvider.cs:line 41
at FollowUpDash.Client.Shared.MainLayout.LogoutClick() in C:\App\sbd\FollowUpDash\FollowUpDash\Client\Shared\MainLayout.razor:line 43
IAuthService.cs line 36
public async Task Logout()
{
var result = await _httpClient.PostAsync("api/auth/logout", null);
result.EnsureSuccessStatusCode();
}
CustomStateProvder.cs line 41
public async Task Logout()
{
await api.Logout();
_currentUser = null;
NotifyAuthenticationStateChanged(GetAuthenticationStateAsync());
}
MainLayout.razor line 43
async Task LogoutClick()
{
await authStateProvider.Logout();
navigationManager.NavigateTo("/login");
}
I don't know to fix this problem. Have you an idea?
Hi, I fix my problem.
The problem was in Program.cs
I've put app.UseRouting();
before
app.UseAuthentication();
app.UseAuthorization();
After this change Logout works.
Thanks to your support.