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?