Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"System.Web.HttpException: Unable to validate data" error in VS Development Server but not in IIS

I am using Visual Studio 2010 SP1 in Windows 7 64bit dev box. My asp.net works fine when using IIS on the box but when I switch to using Visual Studio Development Server, I get an exception "System.Web.HttpException: Unable to validate data" in this line (in Application_AuthenticateRequest event in global.asax.cs):

FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);

Why does this fail when using the internal web server?

like image 989
Tony_Henrich Avatar asked Jan 25 '12 20:01

Tony_Henrich


1 Answers

Try deleting your cookies after you switch servers. Both servers have their own configuration and probably their own decryption key with which the forms authentication cookie is encrypted and decrypted. Thus, if you still have the cookie encrypted by IIS, then switch the project to use the built-in development server and hit the site, that server can't decrypt the cookie.

You can prevent this issue if you put the decryption key in your web.config:

<machineKey decryptionKey="..." />
like image 100
Michiel van Oosterhout Avatar answered Nov 09 '22 02:11

Michiel van Oosterhout