Re: Getting forms auth challenge

From: MarkMurphy (murphy_at_murphysw.com)
Date: 07/29/04


Date: 29 Jul 2004 09:58:15 -0700

Thanks Jim,

I think you meant:

<deny users="?" />
<allow users="*" />

However it's still not redirecting unauthenticated users to
login.aspx. Also it appears that no cookie is being written on a
successful login, though I've verified that this code executes:

//Create an authentication ticket to store in a cookie
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, //Version - change to invalidate cookies
u.UserName,
DateTime.Now, //Authentication time
DateTime.Now.AddMinutes(SessionTimeout), //Time stay authenticated
false, //No persistent cookie
""); //User data

string encryptedTicket = FormsAuthentication.Encrypt(ticket);

Response.Cookies.Add(new
HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket));

string redirectUrl = FormsAuthentication.GetRedirectUrl(u.UserName,
false);

FormsAuthentication.SetAuthCookie(u.UserName, false);

-Mark



Relevant Pages

  • FormsAuthenticationTicket looses UserData
    ... Upon logon I create a ticket and put some userdata in it: ... FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( ... //Hash the cookie for transport ... FormsIdentity id = HttpContext.Current.User.Identity; ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HOW TO: Setting Up Forms Authentication
    ... What defines where the custom cookie is stored? ... string userData = String.Join; ... FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Trying to figure out forms authentication
    ... Can one do one's own checking of username and password and totally bypass calling FormsAuthentication.Authenticate? ... Does the session object get created fresh from every forms submit using the browser's cookie that ASP.Net requests from the browser on every page submit? ... ) {FormsAuthenticationTicket ticket = new ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: FormsAuthentication.SignOut(); doesnt work...
    ... still able to roam about the site - they are never logged off. ... strange thing is that if a user does log back on, it DOES reset the cookie. ... FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( ... string encTicket = FormsAuthentication.Encrypt; ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • forms authentication cookie not timeout
    ... I customized the cookie generation in forms authentication so I can keep ... authentication cookie no longer times out. ... string encryptedTicket = FormsAuthentication.Encrypt; ... HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, ...
    (microsoft.public.dotnet.framework.aspnet.security)