我已经实现了表单身份验证,工作正常,成功注销,但当我的欢迎页面重新发布回来之后,我点击退出按钮它会退出但是,当我点击时...... [英] 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...
问题描述
我已经实现了表单身份验证,它工作正常,成功注销并且没有返回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 yourPage_Init
andPage_Load
of yourLogin.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 yourweb.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 theLoggedInTemplate
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屋!