Overcoming ASP.NET ViewState Validation errors

Sometimes you may encounter a HTTP 500 error when refreshing the page or hitting the Reset page button on a "My..." page often this is due to ASP.NET being unable to validate the view state of the form on the page. This commonly happens when the application pool has been recycled or restarted.

To overcome the error add a static machineKey element as a child of the system.web element. The machineKey element define static validationKey and decryptionKey attributes like the following:

machineKey
<machineKey validationKey="0C14403F4164FDCF6C1A4027FC301D965C7A39DD0A2607BA2A9174D106E930BF7D8E760661D49CCC2CEAF2D3DD8087228F1FEA93E2B0CADFA73B3735FF0E48CA"
decryptionKey="A354D89432D76BBE2A2526F4812AC698B34DA4AEF9E2E8E7"
validation="SHA1"
/>

 

You can generate your own machineKey here (use the ASP.NET 2.0 machineKey option)