Casting Error
Closed this issue · 3 comments
larshittu commented
try
{
var respond = await userService.OnLoginAsync(model);
if (respond.Status)
{
var info = respond.Data as UserIdentity;
((CustomAuthenticationStateProvider)authenticationStateProvider).SignInUserAsync(info);
await _localStore.SetItemAsync(SessionKey.UserIdentity, info);
toastService.ShowSuccess($"Hello {info.DisplayName}, Welcome back.", "Login successful");
NavigationManager.NavigateTo("/");
}
else
{
responsMsg = respond.Data.ToString();
toastService.ShowError(respond.Data.ToString(), "Login error");
}
}
catch (Exception exp)
{
ILogWriter.WriteToLog("Admin", "Login Authentication", "OnLoginAsync", exp.ToString());
toastService.ShowError(exp.ToString(), "Login error");
responsMsg = exp.ToString();
}
--> Unable to cast object of type 'Microsoft.AspNetCore.Components.Server.ServerAuthenticationStateProvider' to type 'Admin.Data.CustomAuthenticationStateProvider'.
SwamiGanesh commented
Hi i have the same error ,i referred few documents and blogs they are doing the same way but not able find what is the problem and solution for this.
SwamiGanesh commented
I removed this code from Startup.cs , everything worked for me
services.AddServerSideBlazor().AddCircuitOptions(options => options.DetailedErrors = true );
larshittu commented
Thanks it works...