Redirect to login page - ASP.NET Core Identity 3 RRS feed

  • Question

  • User-809787061 posted

    I use ASP.NET Core 3 Identity for my application. Application is created by using Angular template (Individual User Accounts) in Visual Studio. Is there any way to show login page when user visits my application? For example, when I type https://localhost:5001 I expect to see only login page without navbar.

    My idea was to modify launchSettings.json and add line "launchUrl": "https://localhost:5001/authentication/login". Is there any better solution?

    Monday, December 9, 2019 7:51 PM


All replies

  • User-474980206 posted

    you can change the default route to login first, but you need to decide what happens when the login cookie expires. how does the angular app detect this. 

    a better approach is to have your webapi return an authentication error that the angular app detects. then the angular app redirects to the login page or implements a login component.

    Monday, December 9, 2019 8:47 PM
  • User-1780421697 posted

    You can use Authentication guards:


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 12, 2019 4:46 AM