SOLVED

Core 5 Razor Pages redirect to custom location login page

Copper Contributor

Hi,

I have created a login page that stands on the root of the application instead of the standard /Account/Login.

 

When attempting to access a page that as the [Authorize] annotation, I keep getting redirected to the standard login location instead of my custom one. 

 

How can I change this so that when the user is not authenticated he gets redirected to /Login instead of /Account/Login?

 

1 Reply
best response confirmed by 0belix (Copper Contributor)
Solution

Found the answer, in case someone stumbles with the same question:

services.ConfigureApplicationCookie(options =>
{
options.LoginPath = "/Login";
options.LogoutPath = "/Logout";
});
1 best response

Accepted Solutions
best response confirmed by 0belix (Copper Contributor)
Solution

Found the answer, in case someone stumbles with the same question:

services.ConfigureApplicationCookie(options =>
{
options.LoginPath = "/Login";
options.LogoutPath = "/Logout";
});

View solution in original post