Forms Auth keeps going to logon page
From: Andy Fraser (news_at_andyfraser.co.uk)
Date: 11/03/03
- Next message: Imtiaz Hussain: "RE: Web Farm and <machineKey>"
- Previous message: dave: "Role Based Solution - Help"
- Next in thread: Cowboy \(Gregory A. Beamer\): "Re: Forms Auth keeps going to logon page"
- Reply: Cowboy \(Gregory A. Beamer\): "Re: Forms Auth keeps going to logon page"
- Reply: alan Hemmings: "Re: Forms Auth keeps going to logon page"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 3 Nov 2003 21:46:36 -0000
Hi,
I am using forms authentication for a web application I am writing. I query
a SQL server database to find a matching username and password then create
an encrypted cookie. I then redirect to my main menu page. However, when I
select a menu and try to jump to another page, it keeps taking me back to my
logon page ! Can anybody suggest what I am doing wrong, I enclose a sample
of my web.config file and a sample of the code that creates the
authentication cookie.
Thanks in advance.
Andy
Web.Config
<authentication mode="None">
<forms name=".RNWEBAUTH" loginUrl="RNLogon.aspx" protection="All"
timeout="60"></forms>
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
Logon.aspx
FormsAuthenticationTicket tkt = new FormsAuthenticationTicket( 1,
Username.Text,
DateTime.Now,
DateTime.Now.AddMinutes( 30 ),
false,
strAccess,
FormsAuthentication.FormsCookiePath );
//
// Hash the cookie for security
//
string hash = FormsAuthentication.Encrypt( tkt );
HttpCookie ck = new HttpCookie( FormsAuthentication.FormsCookieName,hash );
//
// Add cookie to the response
//
Response.Cookies.Add( ck );
Response.Cookies[ "UserID" ].Value = nUserID.ToString();
Response.Cookies[ "UserID" ].Expires = DateTime.MaxValue;
Response.Cookies[ "Access" ].Value = strAccess;
Response.Cookies[ "Access" ].Expires = DateTime.MaxValue;
//
// Jump to main menu page
//
Response.Redirect( strRedirect,true );
- Next message: Imtiaz Hussain: "RE: Web Farm and <machineKey>"
- Previous message: dave: "Role Based Solution - Help"
- Next in thread: Cowboy \(Gregory A. Beamer\): "Re: Forms Auth keeps going to logon page"
- Reply: Cowboy \(Gregory A. Beamer\): "Re: Forms Auth keeps going to logon page"
- Reply: alan Hemmings: "Re: Forms Auth keeps going to logon page"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|