I have a website that uses form authentication. For some reason it works fine at the first run. But on the second run it says too many redirects error.
Loginpage:Load event
protected void Page_Load(object sender, EventArgs e)
{
if (Request.IsAuthenticated)
{
Response.Redirect("HomePage.aspx");
}
}
Login Page submit credentials
protected void btnSubmit_Click(object sender, EventArgs e)
{
int recordExistCount = fc.Authenticate(txtUsername.Text.Trim(), txtPassword.Text.Trim());
if (recordExistCount == 1)
{
Session["User"] = "Authenticated";
Session["Username"] = txtUsername.Text.Trim();
fc.IsOnlineRecord(Session["Username"].ToString(),true);
FormsAuthentication.RedirectFromLoginPage(Session["Username"].ToString(), true);
Response.Redirect("HomePage.aspx");
}
else
{
lblStatus.Text = "Username or password specified are incorrect";
lblStatus.BackColor = Color.Yellow;
}
}
Masterpage signout button
protected void lbSignOut_Click(object sender, EventArgs e)
{
Session.Abandon();
FormsAuthentication.SignOut();
Response.Redirect("LoginPage.aspx");
}
Try this
On LoginPage.aspx
And on MasterPage Markup, place an
asp:LoginStatuslike this