1

I have added a login.aspx to the Default Document section in IIS.

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.

I am redirecting homepage.aspx from login.aspx using web.config. Its like:

<authentication mode="Forms">
      <forms loginUrl="Login.aspx" defaultUrl="Home.aspx"/>
    </authentication>

After some research I found that we need to add this piece of code in page_load of Login.aspx:

if (this.User.Identity.IsAuthenticated)
{
    Response.Redirect("Home.aspx");
}

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.

Does anyone know why this is happening?

Vivek
  • 93
  • 3
  • 12
  • Luckily I am able to get rid of the issue. I made AutoEventWireup="false" in Login.aspx which was set to "True" earlier. – Vivek Apr 25 '15 at 07:56
  • Forgot to mention one more thing. Have removed the code from page_load : if (this.User.Identity.IsAuthenticated) { Response.Redirect("Home.aspx"); } – Vivek Apr 25 '15 at 08:11
  • I don't know why its still not working properly. Sometime users are able to login in the first attempt while sometime we have to click twice on login button. A very strange thing is, if the we close the application without logging-out and then try to log in. In this case, no matter how many times you're clicking on login button, it doesn't log in. In order to get rid of this, we need to publish the project again on IIS. – Vivek Apr 30 '15 at 07:34

0 Answers0