How to fix LoginPath not working in ASP.NET Core
By FoxLearn 2/18/2024 9:42:33 AM 610
This post shows you how to solve 'LoginPath not working in ASP.NET Core'.
By default, if you don't configure it's automatically redirect to "/Account/Login?RedirectUrl=%2F"
Opening your Startup class, then add a configuration as shown below.
services.ConfigureApplicationCookie(options => { options.LoginPath = new PathString("/Identity/Account/Login"); options.ReturnUrlParameter = "RedirectUrl"; options.LogoutPath = new PathString("/Identity/Account/Lockout"); options.AccessDeniedPath = new PathString("/Identity/Account/AccessDenied"); options.ExpireTimeSpan = TimeSpan.FromDays(1); });
Instead of use services.AddAuthentication().AddCookie
services.AddAuthentication().AddCookie(options => { options.LoginPath = "/Identity/Account/Login"; options.ExpireTimeSpan = TimeSpan.FromDays(1); });
- ASP.NET Core: How to Create RDLC Report in ASP.NET Core
- How to fix Assets file 'project.assets.json' not found
- How to fix 'IMvcBuilder' does not contain a definition for 'AddNewtonsoftJson'
- How to fix 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer'
- How to set cookie ValidationInterval in ASP.NET Core
- How to fix Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager'
- How to Configure ASP.NET Core Identity password policy
- How to fix System.InvalidOperationException: Scheme already exists: Identity.Application
Categories
Popular Posts
Visual Studio: Auto increment version
04/01/2024
What is ARM architecture?
04/01/2024
How to use Factory Method Pattern in C#
02/16/2024