ASP.NET core, change default redirect for unauthorized

前端 未结 7 828
抹茶落季
抹茶落季 2020-12-05 09:55

I am attempting to redirect to a different login url in ASP.NET MVC6

My account controller login method has a Route attribute to change the url.

7条回答
  •  一生所求
    2020-12-05 10:13

    You'll need to configure this in startup.cs when adding the authentication service especially if you're using cookie authentication scheme.

    services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options => 
            {
                options.LoginPath = new PathString("/login");
            }); 
    

    This was how i solved the issue, you'll should try it out...It'll definitely work for you

提交回复
热议问题