473,569 Members | 2,845 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET Forms Authentication - How to Know if User Has Previously Been Authenticated

The 2nd parameter of the
[System.Web.Secu rity.FormsAuthe ntication.Redir ectFromLoginPag e(string,
bool)] method controls whether a persistent cookie is created - so that
ASP.NET can "know" if the current user has been previously authenticated
(during previous browser sessions).

My question: How can code I write elsewhere in the application retrieve that
cookie - or otherwise "know" if the current user has been authenticated? My
intent is to have some pages in the application that do not require
authentication in order to be viewed, but do display additional content only
for users who have been authenticated (during the curren session or a
previous browser session). That logic would need to somehow look for the
cookie that was created during authentication or verify that no such cookie
exists. How do I do that?

Thanks
Nov 18 '05 #1
2 2083
"David Krussow" <sc******@schmu ks-r-us.com> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
The 2nd parameter of the
[System.Web.Secu rity.FormsAuthe ntication.Redir ectFromLoginPag e(string,
bool)] method controls whether a persistent cookie is created - so that
ASP.NET can "know" if the current user has been previously authenticated
(during previous browser sessions).

My question: How can code I write elsewhere in the application retrieve that cookie - or otherwise "know" if the current user has been authenticated? My intent is to have some pages in the application that do not require
authentication in order to be viewed, but do display additional content only for users who have been authenticated (during the curren session or a
previous browser session). That logic would need to somehow look for the
cookie that was created during authentication or verify that no such cookie exists. How do I do that?


You don't need to do anything with the cookie.

Request.IsAuthe nticated will tell you if the current request is
authenticated.

--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #2
I'm having the same problem as stated in the start of the thread and
Request.IsAuthe nticated does not work because no methods for
authentication have been called.

My index page allows access to anonymous users via the web.config file,
but I would also like to use user-specific information on that page if
they've been there before How do I access previous presistent cookies
or tickets on a anonymous page?

For example: first, the user logs on to my site and checks "Remember my
ID" (persistent cookie). Then, they close the browser, thus ending the
session. Finally, the user comes back to the index page that users
don't have to be logged in to see, but the this user does see "you are
logged in" because their FormsAuthentica tion ticket was set to
persistent when they first logged in. In this scenario,
Request.IsAuthe nticated = false when they open the new session. If they
go to a protected page, they don't have to log in and now
Request.IsAuthe nticated = true.

Nov 19 '05 #3

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

Similar topics

3
2703
by: Nick | last post by:
I am working a new application...well actually a series of applications for my company. They want internal users to be able to go to a site and everything regarding security is transparent, however we will have brokers and customers that also need to connect and will require a username and password. In this case we were going to store their...
11
3548
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...
0
4208
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET Applications and owner of Access Microsystems. Doug can be reached at doug@accessmicrosystems.com....
1
1670
by: Andy Fish | last post by:
Hi, I have an asp.net web app whereby I authenticate the user with Forms Authentication and store details about him in the session. I want to be able to catch an event when the users authentication period expires but I can't see any way to do this. Currently I have set the forms authentication expiry shorter than the session expiry...
6
517
by: Manny Chohan | last post by:
I am using forms authetication in the web config. i can validate a user against a database and click on images which makes hidden panels visible.However when i click on the link inside a panel which should take user to another pages, it defaults them back to the login page prompting them to enter username and password. Could someone please...
7
2023
by: Justin | last post by:
I am trying to password protect a subdirectory using forms authentication. I am using the "Location" tag to specify the directory to be protected. The login.aspx page is in the root directory of the app. Here is the web.config: <location path="Admin"> <system.web> <authentication mode="Forms"> <forms name="authAdmin" loginUrl="Login.aspx"...
6
7531
by: Kevin Yu | last post by:
is it possible to for user to click a logout button to logout and when the user want to get into the system again, the user have to login again? Kevin
2
2489
by: code | last post by:
Hi, I have stumbled across an interesting problem regarding forms authentication over multiple sub domains. The topic has been covered in various forms online but never really gets a definitive answer as to why it happens. I have two separate web apps sat on different sub domains of the same company realm. eg:
5
3537
by: Rory Becker | last post by:
Having now created a Custom MembershipProvider that seems to work correctly with my Logon and ChangePassword controls, I am, as they say, a happy bunny. The next stange is to move on to the creation of content which adjusts based on the user. I have several pages which require a user to be logged on and several which do not. Prior to this...
0
7695
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...
0
7612
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...
0
8119
jinu1996
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...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
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...
0
6281
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...
1
5509
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...
0
5218
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...
1
2111
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

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.