0

我在后面的 LoginControl.ascx 代码中有这个:

protected void Logout_Click(object sender, EventArgs e)
{
    FormsAuthentication.SignOut();
    Session.Abandon();
    FormsAuthentication.RedirectToLoginPage();
    Response.End;
    //Response.Redirect("default.aspx");
}

我希望在注销时用户将被重定向到登录页面(在这种情况下为default.aspx),并且不会附加任何查询字符串。相反,我在 URL 上看到的是:

http://kab.domain.com/default.aspx?ReturnUrl=%2fAdministration%2fCharacter%2fView.aspx

所以现在,在注销后,我想以另一个人的身份登录(使用较少的权限),并且在成功登录后,它会将我重定向到这个新登录没有权限查看的页面!<grrr />

我意识到“普通”用户永远不会遇到这个问题,但测试用户会遇到,就他们而言,这是一个错误。

即使使用 Response.Redirect 我仍然得到查询字符串。如何在注销时摆脱查询字符串???

4

2 回答 2

0

试试这个:

Response.Redirect(FormsAuthentication.LoginUrl);
于 2009-09-12T17:38:08.480 回答
-1
public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void signout_Click(object sender, EventArgs e)
    {
      Response.Write("<script language=javascript>var wnd=window.open('','newWin','height=1,width=1,left=900,top=700,status=no,toolbar=no,menubar=no,scrollbars=no,maximize=false,resizable=1');</script>");
      Response.Write("<script language=javascript>wnd.close();</script>");
      Response.Write("<script language=javascript>window.open('login.aspx','_parent',replace=true);</script>");
      Session["name"] = null;
    }
}

我还在所有页面上添加此代码。

protected void Page_Load(object sender, EventArgs e)
    {
      Response.Cache.SetCacheability(HttpCacheability.NoCache);
      Response.Cache.SetAllowResponseInBrowserHistory(false);
    }
}
于 2011-03-12T05:05:40.483 回答