简体   繁体   中英

How to change C# Identity Login page default route

I created a new project using Microsoft.Aspnet.Identity.samples for my authentication system.

As you know Visual Studio adds AccountController automatically to the project.

I just edited the Login action route using [Route("login")] attribute.

I added another Controller to my project called Dashboard with an Index method. Then I added an [Authorize] attribute to my dashboard controller.

When I call the URL https://localhost/Dashboard/Index and my request is not authenticated, the project authomaticaly redirects to https://localhost/Account/Login?ReturnUrl=%2Fdashboard and as I said I changed the Login route then my project gives me an error.

How can I change the default login URL?

At the file Startup.Auth.cs is a method called ConfigureAuth you can change the login path default to your custom route.

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