ASP.NET - Logout from code

  • Thread starter Thread starter JackResteBienSurMaisSeraPas
  • Start date Start date
Also to add to Kens post
You might need to make sure that none of the pages are cached. If you're
using a master page, you can put the following code at the beginning of
Page_Load
Response.Expires = 60
Response.Expiresabsolute = Now() - 1
Response.AddHeader("pragma","no-cache")
Response.AddHeader("cache-control","private")
Response.CacheControl = "no-cache"

Hope that helps
Patrick

Ken Cox said:
How are you logged in? If it uses forms authentication, use

FormsAuthentication.SignOut

http://msdn2.microsoft.com/en-us/library/system.web.security.formsauthentica
tion.signout.aspx

Ken
Microsoft MVP [ASP.NET]

JackResteBienSurMaisSeraPas said:
How do you logout from an account from the ASP.NET code?
 
Also to add to Kens post
You might need to make sure that none of the pages are cached. If you're
using a master page, you can put the following code at the beginning of
Page_Load
Response.Expires = 60
Response.Expiresabsolute = Now() - 1
Response.AddHeader("pragma","no-cache")
Response.AddHeader("cache-control","private")
Response.CacheControl = "no-cache"

Hope that helps
Patrick

This seems to work well. Is there a reason not to use it?
 
Back
Top