Change identity login URL in ASP.net core 3.0

Calvin Bootsman

I'm trying to change the default login URL from:

 /Identity/Account/Login

to

/Login

I've looked up similar questions and they came up with a solution similar to this:

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<CompanyLoginContext>(options =>
        options.UseNpgsql(
            Configuration.GetConnectionString("DefaultConnection")));

    services.AddIdentity<CompanyLoginUser, IdentityRole>(options => options.SignIn.RequireConfirmedAccount = true)
       .AddEntityFrameworkStores<CompanyLoginContext>()
       .AddDefaultTokenProviders();

    services.ConfigureApplicationCookie(options =>
    {
        options.Cookie.HttpOnly = true;
        options.ExpireTimeSpan = TimeSpan.FromMinutes(10);

        options.LoginPath = new PathString("/Login");
        options.AccessDeniedPath = new PathString("/Logout");
        options.AccessDeniedPath = new PathString("/AccessDenied");

        options.SlidingExpiration = true;
    }); 
}

But somehow this isn't working.

Rena

Be sure that you have scalffolded Identity,you could refer to here.

Then you need to modify Identity/Account/Login.cshtml like below:

@page "/Login"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive