简体   繁体   中英

Failed to load viewstate in asp.net

I got this problem with asp.net:

Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

Any tips please?

You need to specify a machine key in your web.config. This typically happens when the app get recycled and ASP.Net generates new keys to encrypt/decrypt session state. If you're running a web garden/farm you'll also need to have the same keys on each of the servers. Eg in the system.web section of the web.config file

 <machineKey validationKey="6D1873D8ABE57E15252C4C6A9164F0A1C3E68FBAD8C2F09AEFF178A1269E11FCA4ACAAA628EFAA33FF4C922D638213C63CA6AF76EAEB779D37481CE4ADBC1E7A" decryptionKey="8EA3075B2BB30B0A121BFD283CC78012B83C8D741B846495" validation="SHA1"/>

Google up on this and there are sites that can randomly generate more keys for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM