Sunday, September 18, 2011

Forms authentication failed for the request. Reason: The ticket supplied was invalid.

When was the last time you saw this message ??? (just kidding)

If you drill down to the EventViewer logs you"ll probably see this code

Event code: 4005 Event message: Forms authentication failed for the request. Reason: The ticket supplied was invalid.

Now most people think that this is due to the machine keys in the machine.config file but actually this is due the expiration of a valid ticket which was for a short duration.

After the expiration, the users would need to again sign-on and this makes the user experience even worse. To fix this issue, you need to increase the validity of the ticket by using the sample below

FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, "usercookie", DateTime.Now, DateTime.Now.AddMinutes(120), false);

No comments: