我已经实现了表单身份验证,工作正常,成功注销,但当我的欢迎页面重新发布回来之后,我点击退出按钮它会退出但是,当我点击时...... [英] I Have Implemented Form Authentication, Its Working Fine,Get Succefully Logout, But When My Welcome Page Get Post Back Once Then, I Click On Logout Button Its Get Logout But, When I Click On...

查看:102
本文介绍了我已经实现了表单身份验证,工作正常,成功注销,但当我的欢迎页面重新发布回来之后,我点击退出按钮它会退出但是,当我点击时......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了表单身份验证,它工作正常,成功注销并且没有返回bcak到欢迎页面,但是如果我的欢迎页面得到回发一次然后,我点击注销按钮它得到注销但是,当我点击浏览器后退按钮返回我的欢迎页面。

解决方案

1.在您的 Page_Init 和<$ c您的 Login.aspx.cs 页面的$ c> Page_Load ,用于表单身份验证添加代码,如下一个示例所示。

 受保护  void  Page_Init( object  sender,EventArgs e)
{
if (!IsPostBack)
{
//
// 清除会话缓存数据
//
Session.Clear();
}
}

受保护 void Page_Load( object sender,EventArgs e)
{
if (!IsPostBack)
{
FormsAuthentication.SignOut();

}
// ....
}



2.在 web.config 中,您必须设置表单身份验证,如下一步示例:

 <  身份验证 < span class =code-attribute>   mode   = 表格 >  
< 表单 loginUrl = Login.aspx timeout = 2880 < span class =code-ke yword> / >
< / authentication >



3.在你的主人页面 LoggedInTemplate 部分必须与下一个代码类似:

 <   LoggedInTemplate  >  Hello < ;   span     class  < span class =code-keyword> =  bold >  
< asp:LoginName ID = HeadLoginName runat = server / >
< / span > ! [
< asp:LoginStatus ID = HeadLoginStatus < span class =code-attribute> runat = server LogoutAction = 重定向 LogoutText = 退出

LogoutPageUrl = 〜/ / >
]
< / LoggedInTemplate >



4.退出时间,您可以删除浏览器缓存,如下一篇文章中所示:

HTTP:// stackov erflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers [ ^ ]


< blockquote>您需要清除浏览器历史记录。


i have implemented form authentication, its working fine,get succefully logout and dont return bcak to welcome page, but in case my welcome page get post back once then, i click on logout button its get logout but, when i click on browser back button it returns back to my welcome page.

解决方案

1.In your Page_Init and Page_Load of your Login.aspx.cs page, used for form authentication add the code like in the next example.

 protected void Page_Init(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //
         // Clear the session cached data
         //
         Session.Clear();
     }
 }

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        FormsAuthentication.SignOut();

    }
    //....
}


2.In your web.config you must set form authentication like in the next example:

<authentication mode="Forms">
  <forms loginUrl="Login.aspx" timeout="2880" />
</authentication>


3.In your master page the LoggedInTemplate section must be similar with the next code:

<LoggedInTemplate>Hello<span class="bold">
                                        <asp:LoginName ID="HeadLoginName" runat="server" />
                                    </span>! [
                                    <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Logout"

                                        LogoutPageUrl="~/" />
                                    ]
</LoggedInTemplate>


4.At the logout time, you could delete the browser cache as is indicated in the next article:
http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers[^]


You need to clear browser history.


这篇关于我已经实现了表单身份验证,工作正常,成功注销,但当我的欢迎页面重新发布回来之后,我点击退出按钮它会退出但是,当我点击时......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆