shuvo
July 20th, 2006, 12:52 PM
My OS is XP with service pack 2 installed and Cookies enabled. I am trying to implement Role based security here ...just as the code provided in MSDN.
I am creating a formsauthenticate cookie with the encrypted ticket.So all my user and roles information is stored in my cookie.Problem is when i redirect from the login page and the Application_AuthenticateRequest is invoked.
protected void Application_AuthenticateRequest(object o, EventArgs e)
{
HttpCookie cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if(cookie != null)
{
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
string[] role = new string[]{ticket.UserData};
Context.User = new GenericPrincipal(new FormsIdentity(ticket), role);
}
The cookie is not NULL.But I always get the role =" ", which means the Ticket.UserData is not getting stored in the cookie at all and I am getting role="".I have tried both persistent and nonpersistent cookie.But its the same.can u tell what could be the reason that cookie value is not getting stored.As long as i am in the login page..the values are there, i Have checked it.
I am creating a formsauthenticate cookie with the encrypted ticket.So all my user and roles information is stored in my cookie.Problem is when i redirect from the login page and the Application_AuthenticateRequest is invoked.
protected void Application_AuthenticateRequest(object o, EventArgs e)
{
HttpCookie cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if(cookie != null)
{
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
string[] role = new string[]{ticket.UserData};
Context.User = new GenericPrincipal(new FormsIdentity(ticket), role);
}
The cookie is not NULL.But I always get the role =" ", which means the Ticket.UserData is not getting stored in the cookie at all and I am getting role="".I have tried both persistent and nonpersistent cookie.But its the same.can u tell what could be the reason that cookie value is not getting stored.As long as i am in the login page..the values are there, i Have checked it.