title: ASP.NET Login Control not consistently authenticating
body: <p>I recently inherited an ASP.NET project from another programmer that required consolidating two databases. After consolidating them and fixing the resulting problems in the code I dropped the aspnet membership tables and then recreated them with the aspnet_regsql wizard. I created several users and roles and in my application was able to log in just fine using a standard asp.net login control. I then logged out and tried to log in again and it didn't work.</p>
  
  <p>In an attempt to pinpoint the problem I set breakpoints at the events LoggingIn, Authenticate, and LoggedIn and somehow none of these events are getting fired. The page will validate, but if you enter the correct credentials it seems to just post back without firing any of the login events.</p>
  
  <p>Eventually I got frustrated and moved on to something else. Then today (the next day) I came in and checked again and somehow it let me log in the first time. I tried to log out and log back in and I got the same exact problem. Validation, but no authentication.</p>
  
  <p>Here is the code for my login control:</p>
  
  <pre><code>&lt;asp:Login ID="Login1" runat="server" UserNameLabelText="Username:" PasswordLabelText="Password:" OnLoggedIn="Login1_LoggedIn"&gt;&lt;/asp:Login&gt;
  </code></pre>
  
  <p>The Login1_LoggedIn code-behind:</p>
  
  <pre><code>protected void Login1_LoggedIn(object sender, EventArgs e)
  {
      if (Roles.IsUserInRole(Login1.UserName,"Administrator"))
          Response.Redirect("~/Admin/Default.aspx");
      else if (Roles.IsUserInRole(Login1.UserName,"Appointment Administrator"))
          Response.Redirect("~/ApptReq/Management/ManageEntities.aspx");
  }
  </code></pre>
  
  <p>Web.config membership sections:</p>
  
  <pre><code>  &lt;system.web&gt;
  &lt;authentication mode="Forms"&gt;
    &lt;forms loginUrl="Login.aspx" timeout="60" cookieless="UseCookies" name="Test" slidingExpiration="true" path="/"&gt;&lt;/forms&gt;
  &lt;/authentication&gt;
  &lt;roleManager enabled="true"&gt;
    &lt;providers&gt;
      &lt;clear /&gt;
      &lt;add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="test" applicationName="Test" /&gt;
    &lt;/providers&gt;
  &lt;/roleManager&gt;
  &lt;membership defaultProvider="AspNetSqlMembershipProvider"&gt;
    &lt;providers&gt;
      &lt;clear/&gt;
      &lt;add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="test" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="Test" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" /&gt;
    &lt;/providers&gt;
  &lt;/membership&gt;
  </code></pre>
  
  <p>I'm going crazy trying to figure this thing out, so any help would be greatly appreciated. </p>