FormsAuthentication.SignOut() problem

Z

Zagor

Hi All, (thanks in advance for your time)
I have a standard login.aspx page (UserName\Password). When the user
successully sign in they are redirected to a control panel page
(admin.aspx), which contains a logout button with this code

private void OnLogOutClicked(......)
{
FormsAuthentication.SignOut();
lbStatus.Text= "You have successfully log out";
}

in this same page on PageLoad I have the below code

private void Page_Load(.....)
{
if ( Request.IsAuthenticated = = true ) {...
lbStatus.Text = "User" + User.Identity.Name + "is currenlty logged
in";}
}

The problem is that when the user clicks the "Log Out" button the label
status gets updated(fine) and if the user clicks any other buttons(on the
page) they will be automatically redirect to the login page (fine), which
basically confirm that he\she is logout and no operation can be done on the
page.
Now if I try to type in, the address manually I will be now able to access
the page ( even is no operation can be done) but the label status get
updated as logged in , which means that the user is STILL authenticated. How
can ensure that if your are logged out , the Request.IsAuthenticated will be
false!
Please any help willl be appreciated

Frank
 
H

Hernan de Lahitte

This might be a page local caching issue. When you manually call your
authenticated page (write down the absolute URL to the address bar, what you
actually see is the local cached copy of that page so you are not executing
code on the server side. If you try to do anything that may trigger a server
side event, then you will be redirected to your login page.
If you don´t what your page to be cached locally, you may add this code to
the page load event:

this.Response.Cache.SetCacheability( HttpCacheability.NoCache );


Hernan de Lahitte
http://weblogs.asp.net/hernandl
 

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

Staff online

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top