Asp.net Validation of viewstate MAC failed

前端 未结 16 1703
猫巷女王i
猫巷女王i 2020-12-02 20:12

I am receiving the following error at certain times on asp.net website.

 Sys.WebForms.PageRequestManagerServerErrorException: 
 Validation of viewstate MAC f         


        
16条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 20:50

    Microsoft says to never use a key generator web site.

    Like everyone else here, I added this to my web.config.

    
        
    
    

    However, I used IIS as my machineKey generator like so:

    1. Open IIS and select a website to get this screen:

    1. Double click the Machine Key icon to get this screen:

    1. Click the "Generate Keys" link on the right which I outlined in the pic above.

    Notes:

    • If you select the "Generate a unique key for each application" checkbox, ",IsolateApps" will be added to the end of your keys. I had to remove these to get the app to work. Obviously, they're not part of the key.
    • SHA1 was the default encryption method selected by IIS and if you change it, don't forget to change the validation property on machineKey in the web.config. However, encryption methods and algorithms evolve so please feel free to edit this post with the updated preferred Encryption method or mention it in the notes and I'll update.

提交回复
热议问题