Home All Groups Group Topic Archive Search About

ASP.NET - Logout from code

Author
23 Aug 2006 12:14 AM
JackResteBienSurMaisSeraPas
How do you logout from an account from the ASP.NET code?

Author
23 Aug 2006 1:11 AM
Ken Cox [Microsoft MVP]
How are you logged in? If it uses forms authentication, use

FormsAuthentication.SignOut

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

Ken
Microsoft MVP [ASP.NET]

Show quote
"JackResteBienSurMaisSeraPas" <JackResteBienSurMaisSera***@hotmail.com>
wrote in message news:whNGg.5983$PR5.88501@wagner.videotron.net...
> How do you logout from an account from the ASP.NET code?
>
Author
23 Aug 2006 7:33 AM
Patrick.O.Ige
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 [Microsoft MVP]" <BANSPAMkjopc@newsgroups.nospam> wrote in message
news:#FwSYElxGHA.4876@TK2MSFTNGP05.phx.gbl...
> 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
Show quote
>
> Ken
> Microsoft MVP [ASP.NET]
>
> "JackResteBienSurMaisSeraPas" <JackResteBienSurMaisSera***@hotmail.com>
> wrote in message news:whNGg.5983$PR5.88501@wagner.videotron.net...
> > How do you logout from an account from the ASP.NET code?
> >
>
>
Author
8 Sep 2006 7:33 PM
dgk
On Wed, 23 Aug 2006 17:33:34 +1000, "Patrick.O.Ige"
<naijaco***@hotmail.com> wrote:

>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?

AddThis Social Bookmark Button