RE: Forms Authentication - Sudden Redirect Failure on Login
- From: Stephen Davies <StephenDavies@xxxxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 05:13:04 -0700
Remember this authentication method has been working for 6 months or more
under .net 2.0 and at least 12 months before that under .net 1.1.
The executable currently running on the box is still working!!! Its just
when I recompile this one it fails. Move the executable and pages to another
machines its fine, move it back to this one and it fails. This is what makes
me think its a .net thing not a code this but here it is anyway:
DateTime dtTimeout;
if (bPersistant)
dtTimeout = DateTime.Now.AddMonths(6);
else
dtTimeout = DateTime.Now.AddMinutes(60);
FormsAuthentication.Initialize();
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, // Ticket version
strUser.ToUpper(), // Username associated with ticket
DateTime.Now, // Date/time issued
dtTimeout, // Date/time to expire
bPersistant, // "true" for a persistent user cookie
role, // User-data, in this case the roles
FormsAuthentication.FormsCookiePath); // Path cookie valid for
// Encrypt the cookie using the machine key for secure transport
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);
// Set the cookie's expiration time to the tickets expiration time
if (ticket.IsPersistent) cookie.Expires = ticket.Expiration;
// Add the cookie to the list for outgoing response
Response.Cookies.Add(cookie);
if (redirectURL == null || redirectURL == "noRedirect") return;
Debug.WriteLine("FormsAuthCore set cookie lastlogin->" + strUser.ToUpper());
SetCookie("lastlogin", strUser.ToUpper());
Debug.WriteLine("FormsAuthCore - Redirect to ->" + redirectURL);
Response.Redirect(redirectURL);
The last Debug.WriteLine has the correct redirectURL in it, it is just
intercepted and front ended with the login page once again with the requested
redirect URL (target secured page) in the ReturnUrl querystring variable.
--
Regards
Stephen Davies
"Luke Zhang [MSFT]" wrote:
Hello Stephen,.
Could you please show us the code you used for form authentication, for
example, how did you call RedirectFromLoginPage method in your code? Is
CookiePath specified in the method?
Thanks,
Luke Zhang
Microsoft Online Community Lead
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
- References:
- RE: Forms Authentication - Sudden Redirect Failure on Login
- From: Luke Zhang [MSFT]
- RE: Forms Authentication - Sudden Redirect Failure on Login
- From: Luke Zhang [MSFT]
- RE: Forms Authentication - Sudden Redirect Failure on Login
- From: Luke Zhang [MSFT]
- RE: Forms Authentication - Sudden Redirect Failure on Login
- Prev by Date: Re: OnLoggedIn/OnLoggedOut - not session?
- Next by Date: RE: Forms Authentication - Sudden Redirect Failure on Login
- Previous by thread: RE: Forms Authentication - Sudden Redirect Failure on Login
- Next by thread: RE: Forms Authentication - Sudden Redirect Failure on Login
- Index(es):