如何在c#.net中注销会话 [英] How to Logout the session in c#.net
本文介绍了如何在c#.net中注销会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在c#.net中注销该应用程序Windows应用程序,并且在注销时应打开登录表单.可以提供任何帮助
解决方案
使用
Response.Redirect("login.aspx"); /
如果有任何内容,请清除上一个会话
谢谢,
SP
如果您使用的是FormsAuthentication,请在注销"按钮上单击以编写以下代码
Session.Clear(); Session.Abondon(); FormsAuthentication.SignOut(); Response.Redirect(" );
如果您不使用FormsAuthentication,则只需
Session.Clear(); Session.Abondon(); Response.Redirect(" );将起作用.
FormsAuthentication.SignOut(); 会话[" ].Abandon(); Response.Redirect(" );
并在login.aspx页面加载事件中编写以下语句.
Response.Cache.SetNoStore();
它应该是页面加载事件中的第一声明.
如果您使用的是母版页,则在母版页加载事件中编写以上语句.
I would like to Logout the application in c#.net Windows application and login form should be opened at the time of Logout Can any one help
解决方案
Use
Response.Redirect("login.aspx"); /
Clear previous session''s, if you have any
Thanks,
SP
hi, If you are using FormsAuthentication then on Logout Button click write the following code
Session.Clear(); Session.Abondon(); FormsAuthentication.SignOut(); Response.Redirect("Home.aspx");
and if you are not using FormsAuthentication then simply
Session.Clear(); Session.Abondon(); Response.Redirect("Home.aspx");will work.
Write the followinglogout
code inlogout
button click event
FormsAuthentication.SignOut(); Session["Name"].Abandon(); Response.Redirect("Login.aspx");
and inlogin.aspxpage load event write the following statement.
Response.Cache.SetNoStore();
it should be the first statement in the page load event.
if you are using the master pages then write the above statement in the master page load event.
这篇关于如何在c#.net中注销会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文