Click here to Skip to main content
15,904,348 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I want source code for logout function and once if i logout from my site it should not again return back to the same page it should be in the login page oly
Posted
Comments
[no name] 1-Aug-13 9:02am    
Okay well the sooner you start writing your logout code, the sooner your want will be fulfilled.

1 solution

Basic code would be something like..
C#
protected void Page_Load(object sender, EventArgs e)
{
     Session.Abandon();   //restrict redirecting to same page and browser back button  
     Session.Clear();  
     Response.Redirect(clsCommon.value("login.aspx?mode=logout");
}

Also see..
http://aspnet-with-c-sharp.blogspot.com/2010/12/coding-of-logout-button-in-aspnet-c.html[^]
http://msdn.microsoft.com/en-us/library/aa288576%28v=vs.71%29.aspx[^]
http://stackoverflow.com/questions/1037620/logout-or-signout-problem-in-asp-net-c-sharp-using-master-page-and-windows-authe[^]
 
Share this answer
 
v3
Comments
Adarsh chauhan 2-Aug-13 1:14am    
Good Links... +5
ridoy 2-Aug-13 1:45am    
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900