question

33810499 avatar image
0 Votes"
33810499 asked JanMucha-6496 answered

Blazor Identy using SignInManager from razor page

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?

dotnet-aspnet-core-blazordotnet-aspnet-core-mvc
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AgaveJoe avatar image
0 Votes"
AgaveJoe answered

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JanMucha-6496 avatar image
0 Votes"
JanMucha-6496 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.