Jump to: navigation, search

Unable to validate data

This error occurs on a .net web application runs on a Windows 2003 Server.

Here's the stack trace:

Unable to validate data.

at System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)

Many developers seem to solve the problem at least partially by generating a static key as described in Microsoft's knowledge base: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312906 .

This is a workaround but not an actual solution to the problem, at least in my scenario where my application runs in a dedicated application pool under limited privileges as described in http://msdn2.microsoft.com/en-us/library/ms998297.aspx. The fix is to run aspnet_regiis.exe –ga DOMAIN\USER where USER is the identity of the application pool. Also make sure the user is part of the IIS_WPG group. This command gives not only access to the IIS metabase but also creates the registry keys required in

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0\AutoGenKeys

for the application pool to generate machine keys.


External links

- How to create keys by using Visual C# .NET for use in Forms authentication - http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312906
- How To: Create a Service Account for an ASP.NET 2.0 Application - http://msdn.microsoft.com/en-us/library/ms998297.aspx#paght000009_step1
- Unable to validate data error in relation to machine key - http://jlchereau.blogspot.com/2007/01/unable-to-validate-data-error-in.html