ASP.NET - Logout from code

  • Thread starter JackResteBienSurMaisSeraPas
  • Start date
P

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

dgk

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?
 
Joined
Feb 1, 2008
Messages
1
Reaction score
0
Sorry, I am new here. Don't know how to post a question, so using th Post Reply button:

When I logout, then login again, the application takes me to the login screen,
but the url is "localhost:3263/Login.aspx?ReturnUrl=%2fempty.aspx"
instead of just "localhost:3263/Login.aspx ". It makes me entering UID and PW twice. How can I remove the last part (?ReturnUrl=%2fempty.aspx) programmatically?
Thanks
 

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

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top