title: Login page appears twice in ASP.NET application on IIS
body: <p>I have added a login.aspx to the Default Document section in IIS. </p>
  
  <p>However, when someone was accessing the application, it was required to login twice. The first one wouldn't say any error message or no redirection to the next page in the application. And the second one would actually redirect the user to the expected page. And the user was using the right credentials both times. And on local server, I am able to login in first attempt.</p>
  
  <p>I am redirecting homepage.aspx from login.aspx using web.config. Its like:</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt;
        &lt;forms loginUrl="Login.aspx" defaultUrl="Home.aspx"/&gt;
      &lt;/authentication&gt;
  </code></pre>
  
  <p>After some research I found that we need to add this piece of code in page_load of Login.aspx:</p>
  
  <pre><code>if (this.User.Identity.IsAuthenticated)
  {
      Response.Redirect("Home.aspx");
  }
  </code></pre>
  
  <p>It worked for me but getting some -ve effects. Once you close the application without logging out. And then if you'll try to give the URL of login page, it gives an error. I need to clear the history of browser in order to run it again.</p>
  
  <p>Does anyone know why this is happening? </p>