Invalid viewstate for ScriptResource.axd?

后端 未结 7 633
粉色の甜心
粉色の甜心 2021-02-05 22:27

The Script Resource and the Web Resource files are generating intermittent errors in my application. I have been trying to chase the cause of the problem but to no avail. I noti

7条回答
  •  无人共我
    2021-02-05 23:23

    These errors tend to happen if you are hosting your site on a load-balancing cluster or in a web farm. If you deploy your application in that environment, you must ensure that the configuration files on each server share the same value for validationKey and decryptionKey, which are used for hashing and decryption respectively. This is required because you cannot guarantee which server will handle successive requests.

    With manually generated key values, the settings should be similar to the following example. Please make sure element is underneath section in the web.config file.

    
    

    Here's a nifty little key generator which you can use to generate the key values - http://www.eggheadcafe.com/articles/GenerateMachineKey/GenerateMachineKey.aspx

    So as you might have guessed, the d parameter in the ScriptResource.axd is actually the decryption key, and when that key does not match with the previous request .NET framework will throw an invalid view state error.

    Hope that helps!

提交回复
热议问题