473,386 Members | 1,708 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,386 software developers and data experts.

A little problem with Forms authentication :-(

Hi All,

I'm hoping somebody could help me with the following problem.

I'm using forms authentication and the user is getting authenticated no
problem. Once authenticated the user can look at all the appropriate
pages and so on.

When the user is inactive for a set period of time, I want their
authentication ticket to expire. As I understand it, the next time the
user attempts to access the site after this has happened, the user
should be redirected to the login page. The problem is, this isn't
happening. I've set the time out for the cookie to the test value of 1
min in both the web config file and in code but the user is still
allowed to look around after 1 minute has elapsed. I can't figure out
why though.

In the Web Config file I have:

<authentication mode="Forms">
<forms name="QRVMToken" timeout="1" loginUrl="Login.aspx"
defaultUrl="Secure/Default.aspx"/>
</authentication>

Then in code I have:

// Create a ticket to expire in 1 minute

ticket = new FormsAuthenticationTicket(1, currentUser.QualifiedUsername,
DateTime.Now, DateTime.Now.AddMinutes(1), false, "",
FormsAuthentication.FormsCookiePath);

secureTicket = FormsAuthentication.Encrypt(ticket);

// Add to the cookie collection
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName,
secureTicket));

// Redirect from Login

FormsAuthentication.RedirectFromLoginPage(txtUsern ame.Text, false);

I'm not sure but I think the problem might be something to do with the
redirect from login bit because as I understand it, that method also
adds a cookie and so maybe screwing with the one I've already attached.
The reason why I actually make one is because there doesnt seem to be
anyway to set the expiration of the RedirectFromLoginPage cookie

If anyone could offer some assistance on this I would be very very grateful

Kindest Regards

Simon
Aug 8 '06 #1
3 1306
Simon
What you suspect is 100% correct. Use a different method to get them to the
destination page.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Simon Harvey" wrote:
Hi All,

I'm hoping somebody could help me with the following problem.

I'm using forms authentication and the user is getting authenticated no
problem. Once authenticated the user can look at all the appropriate
pages and so on.

When the user is inactive for a set period of time, I want their
authentication ticket to expire. As I understand it, the next time the
user attempts to access the site after this has happened, the user
should be redirected to the login page. The problem is, this isn't
happening. I've set the time out for the cookie to the test value of 1
min in both the web config file and in code but the user is still
allowed to look around after 1 minute has elapsed. I can't figure out
why though.

In the Web Config file I have:

<authentication mode="Forms">
<forms name="QRVMToken" timeout="1" loginUrl="Login.aspx"
defaultUrl="Secure/Default.aspx"/>
</authentication>

Then in code I have:

// Create a ticket to expire in 1 minute

ticket = new FormsAuthenticationTicket(1, currentUser.QualifiedUsername,
DateTime.Now, DateTime.Now.AddMinutes(1), false, "",
FormsAuthentication.FormsCookiePath);

secureTicket = FormsAuthentication.Encrypt(ticket);

// Add to the cookie collection
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName,
secureTicket));

// Redirect from Login

FormsAuthentication.RedirectFromLoginPage(txtUsern ame.Text, false);

I'm not sure but I think the problem might be something to do with the
redirect from login bit because as I understand it, that method also
adds a cookie and so maybe screwing with the one I've already attached.
The reason why I actually make one is because there doesnt seem to be
anyway to set the expiration of the RedirectFromLoginPage cookie

If anyone could offer some assistance on this I would be very very grateful

Kindest Regards

Simon
Aug 8 '06 #2
Hi there

Thanks for your reply.

I dont know how to redirect them after authentication without using
RedirectFromLoginPage(). That would be fine if I knew how to set the
expiration policy for the cookie that RedirectFromLoginPage() is
creating behind the scenes... Can you advise?

Many thanks

Simon
Aug 9 '06 #3
How about Response.Redirect?

http://www.eggheadcafe.com/articles/20020906.asp

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Simon Harvey" wrote:
Hi there

Thanks for your reply.

I dont know how to redirect them after authentication without using
RedirectFromLoginPage(). That would be fine if I knew how to set the
expiration policy for the cookie that RedirectFromLoginPage() is
creating behind the scenes... Can you advise?

Many thanks

Simon
Aug 9 '06 #4

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

Similar topics

1
by: MJ | last post by:
I'm building an application that has a file structure similar to the following: /myapp/user_login.aspx /myapp/user_page_1.aspx /myapp/user_page_2.aspx /myapp/user_page_3.aspx...
1
by: Scott | last post by:
Hi, We're having an issue with Forms Authentication cookies being treated as expired / invalid, and being deleted. This is causing our intranet users a great deal of pain - Running IIS 5.0 on...
9
by: Hermit Dave | last post by:
Hi, I am making a web application (rather two applications) one which is host and used by customers when they are just browsing through products. The second application resides on a secure...
3
by: Karen A Hodge | last post by:
I have a website that has an Excel template. The template contains 3 QueryTables. The template is located on the web server. I would like to refresh the data prior to the user opening the template...
7
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...
2
by: pv | last post by:
Hi everyone, I need help with following scenario, please: Users are accessing same web server from intranet (users previously authenticated in Active Dir) and from extranet (common public...
1
by: n33470 | last post by:
Hi all, We have an asp.net 1.1 app that we're in the process of converting to 2.0. What I'm about to describe runs just great in the 1.1 framework, but does not work in the 2.0 framework. ...
5
by: Masso | last post by:
Hallo to the group, my question is this: where i have to set timeout in a web application? If i set into sessionState with property Timeout="60", after 20 minutes the session is over. Always...
2
by: Max2006 | last post by:
Hi, We prefer ASP.NET Forms Authentication in our ASP.NET 3.5 application; however we have to use Active Directory for user name and password storage. Is that possible? Is there any sample...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.