Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change identity login URL in ASP.net core 3.0

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.

like image 998
Calvin Bootsman Avatar asked Oct 23 '19 15:10

Calvin Bootsman


1 Answers

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"
like image 120
Rena Avatar answered Sep 19 '22 12:09

Rena