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 2 1983
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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"
|
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...
|
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
|
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
| |
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...
|
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
|
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:
|
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...
|
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...
|
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...
| |
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,...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |