Forms Authentication



Can anyone suggest an example of Forms Authentication?

I'm receiving the following error when trying to run a load test program.

"Cannot set cookies from header server because name-value pair contains
invalid characters"

This the code I'm using to the cookie, but as far I can tell, this should
work.

// Create a new ticket used for authentication
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, // Ticket version
(string)Session["g_Member_Id_Name"], // Member name to be associated
with this ticket
DateTime.Now, // Date/time issued
DateTime.Now.AddMinutes((int)Session["g_Add_Minutes_Num"]), //
Date/time to expire
false, // "true" for a persistent user cookie (could be a checkbox on
form)
(string)Session["g_Member_Type_Name"]); // Member-data (the roles from
this user record in our database)

// Hash the cookie for transport over the wire
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(
FormsAuthentication.FormsCookieName, // Name of auth cookie (it's the
name specified in web.config)
hash); // Hashed ticket

// Add the cookie to the list for outbound response
Response.Cookies.Add(cookie);

Any thoughts appreciated!

Thanks


.



Relevant Pages

  • RE: Forms authentication cookie handling question (C#)
    ... I also replaced all of my ticket authentication code with the ... // Username and or password not found in our database... ... LoginControl's default code logic to generate authentication cookie. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Membership Provider Woes
    ... You set the FormsAuth ticket on the Login_LoggingIn. ... cookie regardless of whether the user's authentication failed or not. ... Doens't the membership provider set a forms auth cookie for me ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Forms authentication cookie handling question (C#)
    ... programmatically generate forms authentication ticket and set it in ASP.NET ... You use the Login control's "Authentication" event to do the user ... LoginControl's default code logic to generate authentication cookie. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Forms authentication cookie handling question (C#)
    ... I'm creating some Forms authentication for a section of my website. ... I think I've even got cookie storage working, ... authentication ticket, ... FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( ...
    (microsoft.public.dotnet.framework.aspnet)
  • Perplexing and critical error - please help!
    ... The site uses Forms authentication w/ anonymous ... pass information about the current conference. ... FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( ... // "true" for a durable user cookie ...
    (microsoft.public.dotnet.framework.aspnet)