ASP.NET - Logout from code

  • Thread starter Thread starter JackResteBienSurMaisSeraPas
  • Start date Start date
J

JackResteBienSurMaisSeraPas

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

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top