Search code examples
asp.net-mvcasp.net-mvc-routingasp.net-mvc-5

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


I started playing around with the ASP.NET MVC 5 preview and everything has been going fine so far (I can only recommend it).

However, I wonder where I can set the Login-Url for the Built-In [Authorize]-Attribute. I've moved the AccountController to a an area, so the path to the Login action is no longer /Account/Login but MyArea/Account/Login, which is ignored by the [Authorize]-Attribute, which in turn means, that whenever one navigates to a controller or action with the attribute set, one is redirected to the wrong path /Account/Login.


Solution

  • 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.