Hi everyone,
I have a menu time called "Logout" and I was wondering how to programmatically log out the current user.
Thanks.
Hi,
you can abandon the session at menu item click and redirect the page to login page.
Session.Abandon();
Response.redirect("login.aspx");
You can link to a page in Menu item "Sign Out" and write all the processing regarding logout in this page.
Also write same logic in "Session_End" event so if user does not click on the logout and close the browser then also logout logic fires,
Hi Thanks to both of your responses, but I am a newbie in web development and if you could tell me how to capture the Session_end event it will be very helpful.
Thanks
Assuming you're using ASP.Net Membership with Forms Authentication, you can also use FormsAuthentication.SignOut() to logout the current user.
Abandoning the session works, but you might be storing other session data not relating to the currently logged-in user which you would want to keep.
Add global.asax in you application through visual studio Add new item it will automatically have
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) ebent for you.
Thanks to all of you for your help. All solutions worked.
0 comments:
Post a Comment