as is the default. So I added @page "/login" to the identity login's .cshtml file, and it works when clicking "log in" in the top nav.
Thing is, with that alone, redirecting from protected pages doesn't work. As in, if I'm not logged in and go to the account settings URL, I get redirected to the default abomination of an URL instead of
/login. And that route doesn't exist now.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
None
0 Points
2 Posts
Problems with routing the default identity pages in an ASP.NET Core with Razor app
Sep 25, 2019 06:02 PM|Angius|LINK
I'm having trouble with login in ASP.NET Core 3.0 app.
Essentially, I want the login page to be at
instead of
as is the default. So I added
@page "/login"
to the identity login's .cshtml file, and it works when clicking "log in" in the top nav.Thing is, with that alone, redirecting from protected pages doesn't work. As in, if I'm not logged in and go to the account settings URL, I get redirected to the default abomination of an URL instead of
/login
. And that route doesn't exist now.In my 2.2 app I could just
and it would work, but in this 3.0 app it breaks login completely. Submitting the login form just redirects to index and the user isn't logged in.
Contributor
2720 Points
874 Posts
Re: Problems with routing the default identity pages in an ASP.NET Core with Razor app
Sep 26, 2019 04:27 AM|Rena Ni|LINK
Hi Angius,
You could configure your CookieAuthenticationOptions like below:
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer( Configuration.GetConnectionString("DefaultConnection"))); services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores<ApplicationDbContext>(); services.PostConfigure<CookieAuthenticationOptions>(IdentityConstants.ApplicationScheme, opt => { //configure your other properties opt.LoginPath = "/login"; }); services.AddControllersWithViews(); services.AddRazorPages();
Reference: https://github.com/Finbuckle/Finbuckle.MultiTenant/issues/78
Best Regards,
Rena
None
0 Points
2 Posts
Re: Problems with routing the default identity pages in an ASP.NET Core with Razor app
Sep 27, 2019 12:41 PM|Angius|LINK
Solved. Using
seems to have fixed the issue.