473,320 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Form Authentication Expiration

Hi all,

I have a site that is compeletely restricted by form authentication.
In the case where a user's cookie expires and then they click on the
logout button on the site, the authetication process is forcing them
to login again so that they can log out.

I've been trying to use
"HttpContext.Current.User.Identity.IsAuthenticated " as the first piece
of code in the "Page_Load" routine, but the server is redirecting the
browser before it gets to it.

Does anyone know of a way to catch the browser before it redirects to
the login page?

My code is as follows:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Verify that user has not timed out.
If HttpContext.Current.User.Identity.IsAuthenticated = False
Then
Me.txtTimeout.Value = "true"
Me.lblLogoutMessage_LABEL.Text = "Cookie is gone."
Else
....
End if
End Sub

Thx,
Rob
Nov 22 '05 #1
2 1959
When you say "the authentication process is forcing them to login again
so that they can log out" this is not actually the case. The user is
already logged out, they are just getting the login page again because
your logout page is designated as not allowing anonymous users...

If your Forms authentication is properly configured (using the
<allow/><deny/> elements) and the user is not authenticated, then
ASP.NET never actually gets to the loading of the requested resource; in
other words, it never gets to your Page_Load event. This is, of course,
by design.

If you want to create a Log out page that will work even if the user is
already logged out, simply make the page accessible to users who are
both logged in and logged out...

<location path="/MyLogoutPage.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>

And then handle that special case on your own using the IsAuthenticated
boolean.

This help?
Sean

Rob Douglass wrote:
Hi all,

I have a site that is compeletely restricted by form authentication.
In the case where a user's cookie expires and then they click on the
logout button on the site, the authetication process is forcing them
to login again so that they can log out.

I've been trying to use
"HttpContext.Current.User.Identity.IsAuthenticated " as the first piece
of code in the "Page_Load" routine, but the server is redirecting the
browser before it gets to it.

Does anyone know of a way to catch the browser before it redirects to
the login page?

My code is as follows:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Verify that user has not timed out.
If HttpContext.Current.User.Identity.IsAuthenticated = False
Then
Me.txtTimeout.Value = "true"
Me.lblLogoutMessage_LABEL.Text = "Cookie is gone."
Else
....
End if
End Sub

Thx,
Rob

Nov 22 '05 #2
That's exactly what I ended up trying at the end of the day yesterday.
Works perfectly.

Thanks!

-Rob
Sean Bright <se**@noreply.com> wrote in message news:<40**************@noreply.com>...
When you say "the authentication process is forcing them to login again
so that they can log out" this is not actually the case. The user is
already logged out, they are just getting the login page again because
your logout page is designated as not allowing anonymous users...

If your Forms authentication is properly configured (using the
<allow/><deny/> elements) and the user is not authenticated, then
ASP.NET never actually gets to the loading of the requested resource; in
other words, it never gets to your Page_Load event. This is, of course,
by design.

If you want to create a Log out page that will work even if the user is
already logged out, simply make the page accessible to users who are
both logged in and logged out...

<location path="/MyLogoutPage.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>

And then handle that special case on your own using the IsAuthenticated
boolean.

This help?
Sean

Rob Douglass wrote:
Hi all,

I have a site that is compeletely restricted by form authentication.
In the case where a user's cookie expires and then they click on the
logout button on the site, the authetication process is forcing them
to login again so that they can log out.

I've been trying to use
"HttpContext.Current.User.Identity.IsAuthenticated " as the first piece
of code in the "Page_Load" routine, but the server is redirecting the
browser before it gets to it.

Does anyone know of a way to catch the browser before it redirects to
the login page?

My code is as follows:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Verify that user has not timed out.
If HttpContext.Current.User.Identity.IsAuthenticated = False
Then
Me.txtTimeout.Value = "true"
Me.lblLogoutMessage_LABEL.Text = "Cookie is gone."
Else
....
End if
End Sub

Thx,
Rob

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob Douglass | last post by:
Hi all, I have a site that is compeletely restricted by form authentication. In the case where a user's cookie expires and then they click on the logout button on the site, the authetication...
0
by: Ben S | last post by:
framework 1.1 in our webapp, we are using forms authentication. ================= Auth Section from web.config ================= <authentication mode="Forms"> <forms name="loginauth"...
11
by: ElmoWatson | last post by:
I tried on the Security newgroup, as well as other places, and haven't gotten an answer yet - - I'm pulling my hair out over this one. I'm trying to get Forms Authentication working.....I can get...
1
by: Do | last post by:
Hi, What's the default expiration for forms authentication? If I hit refresh, will i get redirected to a login page(if the time has expired)? Thanks, Do
0
by: francois | last post by:
hello, I am using forms authentication and I would like that my authentication cookie expires after let say 1 minutes (just for the exemple). When I log in in my longon page, the user has to...
3
by: Martin | last post by:
Dear fellow ASP.NET programmer, I stared using forms authentication and temporarily used a <credentials> tag in web.config. After I got it working I realized this wasn't really practical. I...
11
by: David W. Simmonds | last post by:
I have a form that will prompt for a user name/password. In VS.NET, I have the protected form in a folder named Admin. I have a Web.config file in that folder as well. It contains the following...
1
by: AVance | last post by:
Hi, I've come across this scenario in ASP.NET 1.1 with forms authentication where the forms auth doesn't seem to timeout correctly, nor redirect to the login page. I have done some testing, and...
10
by: Peter Bradley | last post by:
We are in the process of designing our first ASP.NET 2.0 application and have discovered that Forms Authentication works completely differently in ASP.NET 2.0. For a number of reasons, we cannot...
5
by: =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post by:
I have a site which I secure with forms authentication. When the user's sign on and hit one of the secure pages, I have this line in my code to ensure that the browser does not cache the page;...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.