I have a mvc project in developemnt, when a user isn't logged in and trys to go to a page that ISN'T the login or register (AllowAnonymous) they're automatcally redirected to ~/Account/Login?ReturnUrl=%2F"PageTryingToAccess".This is done via a authorization needed statement on the Program.cs.
My login page is the ~/home/(index), the default page on the (portal) website. Is there a way of overiding the ~/Account/Login default? I can not find where this is declared in the solution!
Is there a way of overiding the ~/Account/Login default?
In .net6, you can add below code in Program.cs:
builder.Services.ConfigureApplicationCookie(opts =>
{
opts.LoginPath = "/Home/Index";
});
In asp.net core3, you can use below:
services.ConfigureApplicationCookie(opts =>
{
opts.LoginPath = "/Home/Index";
});
Result: