且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在c#.net中注销会话

更新时间:2023-12-02 13:47:34

使用

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 following logout code in logout button click event
FormsAuthentication.SignOut();
Session["Name"].Abandon();
Response.Redirect("Login.aspx");


and in

login.aspx

page 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.