473,796 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Cu rrent.User.Iden tity.IsAuthenti cated" 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.EventArg s) Handles MyBase.Load
'Verify that user has not timed out.
If HttpContext.Cur rent.User.Ident ity.IsAuthentic ated = False
Then
Me.txtTimeout.V alue = "true"
Me.lblLogoutMes sage_LABEL.Text = "Cookie is gone."
Else
....
End if
End Sub

Thx,
Rob
Nov 22 '05 #1
2 1982
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.as px">
<system.web>
<authorizatio n>
<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.Cu rrent.User.Iden tity.IsAuthenti cated" 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.EventArg s) Handles MyBase.Load
'Verify that user has not timed out.
If HttpContext.Cur rent.User.Ident ity.IsAuthentic ated = False
Then
Me.txtTimeout.V alue = "true"
Me.lblLogoutMes sage_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.c om> 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.as px">
<system.web>
<authorizatio n>
<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.Cu rrent.User.Iden tity.IsAuthenti cated" 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.EventArg s) Handles MyBase.Load
'Verify that user has not timed out.
If HttpContext.Cur rent.User.Ident ity.IsAuthentic ated = False
Then
Me.txtTimeout.V alue = "true"
Me.lblLogoutMes sage_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
374
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 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
0
2175
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" path="/" loginUrl="loginauth.aspx"
11
3607
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 any requested page to automatically go to the Login.aspx page, AND, the ReturnURL querystring is correct in the address bar, but no matter what, I can't get it, once the user is authenticated, to redirect to the new page. It ALWAYS refreshes the...
1
1186
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
1245
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 input a username, password and the click a button to effectively login. In the event handler for my button I have the following code: // create authentication ticket and encrypt it
3
4744
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 cannot write to web.config so I cannot dynamically update the credentials while the site is up. Since the FormsAuthentication.Authenticate() method's documentations claims the following: "Attempts to validate the credentials against those contained...
11
2973
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 section: <authorization> <deny users="?" /> <allow users="*" /> </authorization> In the root folder where the other forms are located I have a Web.config
1
2196
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 I believe I've found a solution, but I would like some insight from Microsoft on whether the code I've implemented is correct, and why it is even working. Here is my scenario:
10
5255
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 use the standard login component supplied with ASP.NET 2.0 (e.g. we need full control of the look and feel - including using CSS and not tables for layout - and we need to be able to handle the authentication cookie ourselves rather than let a...
5
6800
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; and someone cannot navigate back to an cached image of the page in theory after the user has signed off. Response.Cache.SetCacheability(HttpCacheability.NoCache); This works all right, except when the user decides to use the browser's back...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10465
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6800
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4127
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.