ASP.NET MVC 5 (Visual Studio 2013 Preview) Change Login Url for [Authorize]

六眼飞鱼酱① 提交于 2019-11-28 14:04:12

Look in web.config for a section like this:

<authentication mode="Forms">
  <forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>

Change the loginUrl value to point to your updated login page.

When using the new OWIN forms authentication (as opposed to the old ASP.NET forms authentication), this gets set in the Startup class. In the default templates, it's in App_Start/Startup.Auth.cs in the ConfigureAuth method:

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