Asp.net Core Authorize Redirection Not Happening

这一生的挚爱 提交于 2019-12-04 05:11:27
BigONotation

OK figured it out. It is all explained here: https://docs.asp.net/en/latest/security/authentication/cookie.html

I was missing the options.AutomaticChallenge = true;, which automatically redirects you to the Login Controller.

Here is the updated options:

app.UseCookieAuthentication(options => {
                options.LoginPath = new Microsoft.AspNet.Http.PathString("/Login");
                options.AutomaticChallenge = true;
            });

UPDATE:

As of version 1.1.0 it's:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
         LoginPath = new Microsoft.AspNetCore.Http.PathString("/Account/Login"),
         AutomaticChallenge = true
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!