简体   繁体   中英

How To Make Identity Login Page As Startup Page And Redirect User to Dashboard If User Is Already Logged-in In Blazor Server

Here I have simple chat blazor server app, where user login, add friend and can chat with added friends.
In app there is identity login, register etc which is created while creating project by selecting authentication type as Individual Accounts .

Now, what I want is to make identity login page as my default starting page, after login redirect blazor dashboard and if user is already logged-in redirect that user to dashboard.

Any help to achieve these thing be grateful. Thank you

sudip chand, what is wrong with the current design of your app? I wouldn't do what you ask, even if you are not the first user asking for this design. Your current design allow access to the chat page only if the user is authenticated. I think it's the correct design.

However, if you want to make the identity login page as your default starting page you can add @attribute [Authorize] to the top of your _Host.cshtml file. This will ensure that, if the user is not authenticated, the Login page, which is not part of the Blazor App, would be displayed even before the Blazor App is completely rendered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM