# Custom LoginPath no effect in ASP.NET MVC

**URL:** <https://community.auth0.com/t/custom-loginpath-no-effect-in-asp-net-mvc/94972>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [November 23, 2022, 8:55am UTC](https://community.auth0.com/t/custom-loginpath-no-effect-in-asp-net-mvc/94972 "2022-11-23T08:55:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zuhao](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zuhao/32/41456_2.png) [@zuhao](https://community.auth0.com/u/zuhao)\
**Post date:** [November 23, 2022, 8:55am UTC](https://community.auth0.com/t/custom-loginpath-no-effect-in-asp-net-mvc/94972/1 "2022-11-23T08:55:09Z")

</div>

In my [ASP.NET](http://ASP.NET) MVC project, the default login path is /Account/Login. I want to configure It to be /User/Login when [Authorize] tag is used on the controller.

The following is the relevant code in Program.cs, it seems the setting in `ConfigureApplicationCookie` has no effect. It still redirects to /Account/Login.

```auto
using Auth0.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContextFactory<ApplicationDbContext>(options => options.UseSqlite(devConnString));
builder.Services.AddDatabaseDeveloperPageExceptionFilter();

builder.Services.ConfigureApplicationCookie(options =>
{
    options.LoginPath = new PathString("/User/Login");
    options.LogoutPath = new PathString("/User/Logout");
});

builder.Services.AddAuth0WebAppAuthentication(options =>
{
    options.Domain = builder.Configuration["Auth0:Domain"];
    options.ClientId = builder.Configuration["Auth0:ClientId"];
});

builder.Services.AddRazorPages();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseMigrationsEndPoint();
}
else
{
    app.UseExceptionHandler("/Home/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();
app.UseResponseCaching();
app.UseAuthentication();
app.UseAuthorization();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");
app.MapRazorPages();

app.Run();

```

---

<div class="post-metadata">

**Author:** ![scidec](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@scidec](https://community.auth0.com/u/scidec)\
**Post date:** [July 13, 2023, 5:20pm UTC](https://community.auth0.com/t/custom-loginpath-no-effect-in-asp-net-mvc/94972/2 "2023-07-13T17:20:13Z")

</div>

This is super annoying for me, is there an answer for this?

---

<div class="post-metadata">

**Author:** ![zuhao](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zuhao/32/41456_2.png) [@zuhao](https://community.auth0.com/u/zuhao)\
**Post date:** [July 14, 2023, 12:59am UTC](https://community.auth0.com/t/custom-loginpath-no-effect-in-asp-net-mvc/94972/3 "2023-07-14T00:59:21Z")

</div>

Please see this [c# - Custom LoginPath no effect in ASP.NET MVC with Auth0 - Stack Overflow](https://stackoverflow.com/questions/74555220/custom-loginpath-no-effect-in-asp-net-mvc-with-auth0)

After a long while finally some one managed to help provide a solution.

---

<div class="post-metadata">

**Author:** ![scidec](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@scidec](https://community.auth0.com/u/scidec)\
**Post date:** [July 14, 2023, 5:34am UTC](https://community.auth0.com/t/custom-loginpath-no-effect-in-asp-net-mvc/94972/4 "2023-07-14T05:34:25Z")

</div>

OK, many thanks, works now

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 14, 2023, 10:20am UTC](https://community.auth0.com/t/custom-loginpath-no-effect-in-asp-net-mvc/94972/5 "2023-07-14T10:20:11Z")

</div>

Thanks for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [July 28, 2023, 10:20am UTC](https://community.auth0.com/t/custom-loginpath-no-effect-in-asp-net-mvc/94972/6 "2023-07-28T10:20:30Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
