Asp.net 表单身份验证太多重定向问题
我有一个使用表单身份验证的网站。出于某种原因,它在第一次运行时运行良好。但在第二次运行时,它表示重定向错误太多 登录页面:加载事件Asp.net 表单身份验证太多重定向问题,asp.net,Asp.net,我有一个使用表单身份验证的网站。出于某种原因,它在第一次运行时运行良好。但在第二次运行时,它表示重定向错误太多 登录页面:加载事件 protected void Page_Load(object sender, EventArgs e) { if (Request.IsAuthenticated) { Response.Redirect("HomePage.aspx"
protected void Page_Load(object sender, EventArgs e)
{
if (Request.IsAuthenticated)
{
Response.Redirect("HomePage.aspx");
}
}
登录页面提交凭据
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;
}
}
母版页签出按钮
protected void lbSignOut_Click(object sender, EventArgs e)
{
Session.Abandon();
FormsAuthentication.SignOut();
Response.Redirect("LoginPage.aspx");
}
试试这个
关于LoginPage.aspx
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["action"] != null && Request.QueryString["action"] == "logout")
{
Session.Abandon();
FormsAuthentication.SignOut();
}
else
{
if (HttpContext.Current.User.IsAuthenticated)
{
Response.Redirect("HomePage.aspx");
}
}
}
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);
}
else
{
lblStatus.Text = "Username or password specified are incorrect";
lblStatus.BackColor = Color.Yellow;
}
}
在母版页标记上,像这样放置一个asp:LoginStatus
<asp:LoginStatus ID="AdminLoginStatus" runat="server"
LogoutAction="RedirectToLoginPage"
LogoutText="Log Out"
LogoutPageUrl="~/LoginPage.aspx?action=logout"/>
让我看看你的web.config表单tagi@naveen有同样的错误,下面是我的web.config文件数据。。参见代码