title: Upgrading to ASP.NET 4.5/MVC 4 forms authentication fails
body: <p>I've just downoaded a VS 2012 along with ASP.NET 4.5 and MVC 4.0 and was kicking the tires with a sample app and found that the forms authentication that works perfectly with ASP.NET 4.0/MVC 3 no longer seems to work with the latest release.</p>
  
  <p>When I make a call to the Login function in the action controller, the WebSecurity.Login call fails:</p>
  
  <pre><code>public ActionResult Login(LoginModel model, string returnUrl)
  {
      if (ModelState.IsValid &amp;&amp; WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
      {
          return RedirectToLocal(returnUrl);
      }
  
      // If we got this far, something failed, redisplay form
      ModelState.AddModelError("", "The user name or password provided is incorrect.");
      return View(model);
  }
  </code></pre>
  
  <p>I've replaced this code with the equivalent in my VS 2010 source, and that also fails (using the now deprecated FormsAuthentication.Authenticate function).</p>
  
  <p>My question is:  Has anybody ported a MVC3 to MVC4 app and found a workaround to this issue?  I'm using IIS Express, so I guess that may be causing some problem somehow, but if you have any ideas, I'd appreciate it.</p>
  
  <p>I copied my configuration from my working asp.net 4/MVC3 app as follows, but no luck (here's the relevant parts):</p>
  
  <pre><code>  &lt;connectionStrings&gt;
      &lt;add name="DefaultConnection" connectionString="Data Source=tcp:sql2k1201.dbprovider.net;Initial Catalog=SQL2012_db;User ID=SQL2012_db_user;Password=dbpassword;" providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
  
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5" /&gt;
      &lt;httpRuntime targetFramework="4.5" /&gt;
  
      &lt;authentication mode="Forms"&gt;
        &lt;forms loginUrl="~/Account/Login" timeout="2880"/&gt;
      &lt;/authentication&gt;
  
      &lt;membership&gt;
        &lt;providers&gt;
          &lt;clear/&gt;
          &lt;add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="DefaultConnection"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
             applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/membership&gt;
  
      &lt;profile&gt;
        &lt;providers&gt;
          &lt;clear/&gt;
          &lt;add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="DefaultConnection" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/profile&gt;
  
      &lt;roleManager enabled="true"&gt;
        &lt;providers&gt;
          &lt;clear/&gt;
          &lt;add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="DefaultConnection" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/roleManager&gt;
  </code></pre>