.Net ramblings
# Monday, 30 January 2006
Fix: Unable to validate data, MachineKey.GetDecodedData
i kept getting these sporadic error messages on my web applications and i could never figure out why. 
Unable to validate data at
System.Web.Configuration.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) at
System.Web.UI.LosFormatter.Deserialize(String input)
searching the net just reveals a troop of similarly frustrated users without solutions.  but today i found the actual reason why, and the work-around.
this excellent post on experts-exchange has the answer.  apparently it happens when users leave a page open for a long time, and then cause a post back.  something to do with the machine key being automatically generated and it changes before the user causes the postback, and it can't validate it then. 
the fix is to set a static machine key. 
There is a kb article with some code to generate a key for you, + instructions.  


Monday, 30 January 2006 22:53:44 (GMT Standard Time, UTC+00:00)  #    Comments [13]  .Net General | Asp.NetTracked by:
http://www.google.com/search?q=qspkwjin [Pingback]
http://www.google.com/search?q=ktnaxptg [Pingback]

Friday, 16 June 2006 18:36:49 (GMT Daylight Time, UTC+01:00)

Thanks for the article. I do have WebFarm and both the machines have the same static key. However, we still gets such errors twice a week or so. Can you think of anyother solutions?

Friday, 16 June 2006 19:09:47 (GMT Daylight Time, UTC+01:00)
hi shyam,
you're right, the solution i posted helped the situation somewhat, but i still get occasional errors. i have never seen it happen in my .Net 2.0 applications, so maybe we'll just have to put up with it until the application can be moved to a .net 2.0 environment.

sorry i don't have a better answer.
Tuesday, 27 June 2006 13:41:49 (GMT Daylight Time, UTC+01:00)

I did try the solution from the kb and atleast the errors have abated. I had to use the "AutoGenerate" settings as I am clueless as to how to use the Cryptographic Classes mentioned to create encryption/decryption keys.

To be honest, every little solution helps. And well, I try and tell my clients somehow: dont leave your form half filled and wonder off to have a coffee!!! (not that that would work!)

once again: U R DA MAN!
Tuesday, 31 October 2006 17:56:07 (GMT Standard Time, UTC+00:00)
I also want to know, how to give value for the autogenerate setting.

Thursday, 04 January 2007 17:39:49 (GMT Standard Time, UTC+00:00)
I have experienced the same problem and in my scenario, creating a static key is a workaround but not a fix.
The fix requires creating registry entries for the identity of the application pool that executes the ASP.NET application. For more info, see: http://jlchereau.blogspot.com/2007/01/unable-to-validate-data-error-in.html
Sunday, 25 March 2007 06:12:06 (GMT Daylight Time, UTC+01:00)
I hae found same error.
please help me.
Thursday, 01 November 2007 10:58:41 (GMT Standard Time, UTC+00:00)
I am still getting this error in 2.0, so far I have tried everything. And I still get it. I have read every MS KB and tried there hot fixes. but yet I still get it. I am thinking it may have something to do with Dell Servers as this is the first time I am getting this problem, and it is the first time I am hosting a website on a Dell Server.
Wednesday, 17 September 2008 11:09:18 (GMT Daylight Time, UTC+01:00)
I get this error - but this is critical - IT ONLY HAPPENS IN FIREFOX!!!! - the same page works fine in IE, but non-IE browsers throw up the "Unable to validate data" exception. The page is nothing special either. Just a couple of images, a textbox and a button. What on earth is the problem?
Wednesday, 17 September 2008 11:13:55 (GMT Daylight Time, UTC+01:00)
hi owen, i explain the problem + workaround in the article!! it isn't anything to do with browers, it's just by chance that it happens when using FF.
tim mackey
Tuesday, 23 June 2009 14:13:04 (GMT Daylight Time, UTC+01:00)
Hi, Thanks for wonderful article.
Can you please include the full solution from "http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21321364.html" .

apprently that web address require membership.

Thanks in advance
Jaswinder Singh
Tuesday, 23 June 2009 14:37:38 (GMT Daylight Time, UTC+01:00)
hi jaswinder, yes experts-exchange have totally removed access for non-members. in any case the KB article has more info. best of luck
Thursday, 25 June 2009 17:15:46 (GMT Daylight Time, UTC+01:00)
Hey guys -

Just an FYI - you can see Experts Exchange solutions if you arrive from a google search.

The easiest way to do it, is to take the URL of an experts exchange page, and just search it in google, and follow that result. Just scroll to the bottom and you'll see.

I don't know -why- they do this, but I'm sure glad they do. :)
Friday, 04 June 2010 20:00:56 (GMT Daylight Time, UTC+01:00)
I finally got fed up with these sporadic errors today and decided to do something about it. Your brief article pointed me in the right direction to fix this problem that I've been ignoring for the last few years. Thank you!
Please login with either your OpenID above, or your details below.
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

[Captcha]Enter the code shown (prevents robots):

Live Comment Preview