B
Bruce
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
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