Why does this forms authentication require double login sometimes?
<p>I am trying to implement forms authenication in ASP.NET 2010 through a login page and a database table of usernames and passwords.</p>

<p>Some of the time some of the users must authenicate twice, which is getting annoying to those users and they are complaining.</p>

<p>In the web.config I have</p>

<pre><code>&lt;authentication mode="Forms"&gt;
  &lt;forms loginUrl="WebFormLogon.aspx" defaultUrl="WebformHomepage.aspx"/&gt;
&lt;/authentication&gt;
</code></pre>

<p>In the code behind file after validating the password and username I do the following:</p>

<pre class="lang-cs prettyprint-override"><code>    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
      username,
      DateTime.Now,
      DateTime.Now.AddMinutes(60),
      isPersistent,
      userData,
      FormsAuthentication.FormsCookiePath);

    // Encrypt the ticket.
    string encTicket = FormsAuthentication.Encrypt(ticket);

    // Create the cookie.
    Response.Cookies.Add(new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

    string redirectpage = FormsAuthentication.GetRedirectUrl(username, isPersistent);
    Response.Redirect(redirectpage);
</code></pre>
