Aspnetcore: Using Blazor components to customize the security pages

Created on 20 Jun 2019  路  2Comments  路  Source: dotnet/aspnetcore

Is your feature request related to a problem? Please describe.

The current solution for authentication and authorization relies on the default Razor pages (register, login etc). As far as I know one can scaffold them in order to customize them. Those pages are Razor (not Blazor) and as a result I can't use any Blazor components that I have.

Describe the solution you'd like

I would like to use Blazor pages instead of Razor ones to customize the Identity related capabilities.

Describe alternatives you've considered

We tried using custom Blazor pages that invoke SignInManager.PasswordSignInAsync. This however fails with The response headers cannot be modified because the response has already started because the whole thing works inside 邪 SignalR connection. Making this work somehow is also a viable solution.

area-blazor

All 2 comments

It turns one one can use a Blazor component in a Razor page via Html.RenderComponentAsync. This will get the HTML output of a third party Blazor component but event handling won't work.

Maybe the solution is to authenticate via JavaScript so the authentication cookie reaches the client.

The default Identity UI is actually based on Razor Pages, not Blazor. We could at some point decide to provide an alternative implementation of the default Identity UI using purely Blazor components, but that鈥檚 not something we plan to do right now.

Blazor is intended to be complimentary to our existing server-side rendering technologies, like MVC & Razor Pages. You should be able to customize the default Identity UI by scaffolding out the different Razor Pages that you want to change into your app. You can also use components in a Razor Pages or MVC View. These components can be interactive, but you need to make sure the blazor.server.js script is included in the page.

There are some issues with the scaffolded code right now that we are working to address for the next preview update.

I hope this helps!

Was this page helpful?
0 / 5 - 0 ratings