Blazor Identy using SignInManager from razor page

마루 라온 21 Reputation points
2021-08-24T06:17:26.507+00:00

In blazor server i could add Identity scafold to my project and i used this.
But this is written with cshtml and uses Mvc Logics.

So without knowledge with AspNetCore Mvc i started implementing custom login and out.
The Login page was needed so i used it.
But Logout page is not needed.

So i added a click event and Injected SignInManager
@inject SignInManager<IdentityUser> SignInManager

and called
SignInManager.SignOutAsync();

And... it didn't worked well.
I couldn't use debugger because the error was hidden behind code so i couldn't see.

So. here's a Question.
How can i Use asp net core Functions.
And how can i call them from blazor?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,244 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,422 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. AgaveJoe 26,166 Reputation points
    2021-08-24T11:52:49.897+00:00

    The SDK comes with project templates that include authentication and authorization. I recommend creating a new project using one of the templates. Then review the code to understand how to configure authentication/authorization in a Blazor application.

    Blazor WASM
    Blazor Server

    0 comments No comments

  2. Jan Mucha 101 Reputation points
    2021-11-05T09:19:58.697+00:00

    Hello, SignInManager use Http request resposne communication, but blazor is on web socet communication. For example you cannot use cookies in blazor. SignInManager unfortunatly does not work on blazor.
    Try read this article https://startblazoring.com/Blog/SignInManager

    0 comments No comments