Invalid viewstate Error

Source: Internet
Author: User
We have been getting some questions regarding viewstate-related errors like "The viewstate is invalid for this page and might be too upted"

This error is usually caused by the ASP worker process or the server retries ing. by default, Asp. net encrypts the viewstate using an autogenerated key when the process spins up. the problem comes when a client (browser) sends the request with a viewstate encrypted with the key generated by another worker process. since the key is different, Asp. net will not be able to decrypt the viewstate and it will throw the above error.

There are several ways to get around this problem:

1) host your site on a server that never restarts or recycles !!! Obviusly, this is impossible!

2) Disable viewstatemac by putting this? Enableviewstatemac = 'false '? In your web. config. This approach is not 100% secure.

3) Configure ASP. NET to not use auto-generated key but rather a predefined key. This is the preferred method.

To do this, follow these steps:

A) either build your own key generator (http://support.microsoft.com/kb/313091/EN-US/) or use this tool (http://www.aspnetresources.com/tools/keycreator.aspx). I highly recommend you use the online tool. So assuming you will use the online tool:

B) in the online tool, simply click on? Generate ?.

C) copy the content in the textbox into your site? S web. config file. The machinekey node shoshould be within <system. Web>

Eg.

<Configuration>
<Appsettings/>
<Connectionstrings/>
<System. Web>
<Machinekey
Validationkey = '2eea416cefc6d6be856ed57b97fb9ca7dfa ce17c073125949a1d682c80a44bb2a
D887dddc13dbfb0954f1000fee5757e99693f222f8e28caa2e 6dab8c4f99e0c'
Decryptionkey = '877478b2f33a74226abef55fdcc1a76e43f 1bbea6241a592'
Validation = 'sha1'/>
<Compilation DEBUG = 'false'/>
<Authentication mode = 'windows'/>
<Pages enableviewstatemac = 'true'/>
</System. Web>
</Configuration>

For more information on viewstate troubleshooting, see http://support.microsoft.com/default... B ;EN-US;829743

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.