title: System.Web.HttpContext.Current.User.Identity.IsAuthenticated fails sometimes
body: <p>I have been having trouble with my production site (not my development sites).  Every now and then both Firefox and Chrome fail to log users in (all users both on our client network and general web). But the strange part is that Internet Explorer always works correctly and has NEVER failed once (I have delete cache and cookies in browsers but still the same thing happens).</p>
  
  <p>Then after an hour or X amount of time, Firefox and Chrome start behaving normally again.</p>
  
  <p>I have a narrowed it down to function below that always returns false even after login.</p>
  
  <pre><code>public bool isLoggedIn()
  {
      return System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
  }
  </code></pre>
  
  <p>So the process goes below with the user going to login with this function:</p>
  
  <pre><code>public void Login_OnClick(object sender, EventArgs args)
  {
      string email = UserName.Text;
      string password = Password.Text;
      string errorMsg = string.Empty;
      bool cb = cb_agreeterms.Checked;
  
  if (tests)
      {
          // The code in here tests to see if email, password, etc. have been filled out.
          //  This works 100% of the time and is NOT a problem.
      }
      else
      {
          // Validate user.
          if (Membership.ValidateUser(email, password))
          {
              // Get the logged in user
              MembershipUser user = Membership.GetUser(email);
  
              if (user.IsLockedOut)
              {
                  user.UnlockUser();
              }
  
      // Gets a datatable of the user details in our general database
              DataTable dtUserData = this.dbData.GetUserByEmail(user.UserName);
  
              if (dtUserData.Rows.Count &gt; 0)
              {
                  FormsAuthentication.SetAuthCookie(user.UserName, true);
  
                  // The details for the userId, screenName, etc. below get set by looking at the row 0 in datatable
  
          // The LoginSession function intializes a session with a guid and saves all the data into an Application Context. This creates a SessionGuid cookie which I see get created on FF and Chrome (and always on IE).
                  LoginSession(userId, screenName, permissionLevel, user.UserName);
  
                  Response.Redirect("../myinternalsite.aspx");
              }
          }
          else if (UserExistsInMembership(email))
          { 
              // Tested this out and entering bad credentials fails the login and error is shown correctly on screen in the login control.
  
              // We have failed to login.
              ShowLoginError("E-mail or password is incorrect.");
          }
      }
  }
  </code></pre>
  
  <p>So when the user authenticates, the redirect goes to ../myinternalsite.aspx.  On the page in Page Load a VerifyLogin function gets called and calls:</p>
  
  <pre><code>public bool isLoggedIn()
  </code></pre>
  
  <p>The above ALWAYS returns falso in Chrome and FF which prompts a redirect to the home page.  After a couple hours this fixes itself. IE works 100% of the time.</p>
  
  <p>The web.config is this:</p>
  
  <pre><code>// authenticationConnection works and links correctly to the auth database just fine.
  &lt;sessionState timeout="120"/&gt;
  
  &lt;membership defaultProvider="SqlProvider"&gt;
  
      &lt;providers&gt;
  
          &lt;add connectionStringName="authenticationConnection" applicationName="Auth" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" requiresQuestionAndAnswer="false" passwordFormat="Hashed" enablePasswordReset="true" maxInvalidPasswordAttempts="1000" passwordAttemptWindow="1" /&gt;
  
      &lt;/providers&gt;
  
  &lt;/membership&gt;
  
  &lt;roleManager enabled="true" defaultProvider="SqlRoleManager"&gt;
  
      &lt;providers&gt;
  
          &lt;add name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="authenticationConnection" applicationName="MyApp"/&gt;
  
      &lt;/providers&gt;
  
  &lt;/roleManager&gt;
  
  &lt;identity impersonate="true"/&gt;
  </code></pre>
  
  <p>The cookies in Chrome and Firefox get set. I deleted them and saw them get reset correctly. But what is this issue?  Why is IsAuthenticated failing for only some browsers and working for others and then fixes itself?</p>
  
  <p>My login template with all my different steps is something like this too:</p>
  
  <pre><code>&lt;asp:UpdatePanel ID="updateTheLogin" runat="server"&gt;
      &lt;ContentTemplate&gt;
           &lt;asp:TextBox ID="UserName" runat="server" CssClass="loginTextbox"&gt;&lt;/asp:TextBox&gt;
           &lt;asp:TextBox id="Password" runat="server" textMode="Password" CssClass="loginTextbox"&gt;&lt;/asp:TextBox&gt;
           &lt;input type="button" class="btn-small pull-right disabled" id="LoginButton" value="Log In" onserverclick="Login_Click" runat="server" /&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>