I have the subject error on the following line of code:
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Request.Cookies["UserData"].Value);
=====
The next code sets the cookie:
bool isPersistent;
// if the user want to be remembered next time
if (this.RememberMe.Checked == true)
{
FormsAuthentication.SetAuthCookie(this.txtLogonName.Text, true);
isPersistent = true;
}
else
{
FormsAuthentication.SetAuthCookie(this.txtLogonName.Text, false);
isPersistent = false;
}
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
txtLogonName.Text,
DateTime.Now,
DateTime.Now.AddDays(30),
isPersistent,
string.Empty,
FormsAuthentication.FormsCookiePath);
// Encrypt the ticket
string encryptedTicket = FormsAuthentication.Encrypt(ticket);
// Create the cookie
HttpCookie cookie = new HttpCookie("UserData", encryptedTicket);
cookie.Expires = DateTime.Now.AddDays(30);
cookie.Path = "/";
Response.Cookies.Add(cookie);
Response.Redirect("secure/Default.aspx", false);
}
What causes this error?