In ASP.Net, I sometimes get the following error - Viewstate verification failed. Reason: The viewstate supplied failed integrity check

蹲街弑〆低调 提交于 2019-11-30 14:35:51

This issue can often be caused by having auto-generated <machineKey /> keys in your server's machine.config file. Each time your application starts afresh it will generate new keys. This invalidates any existing encrypted viewstate or forms authentication tickets.

Try setting the <machineKey /> validationKey and decryptionKey to fixed values. See the following link for more information:

How To: Configure MachineKey in ASP.NET 2.0 (MSDN)

I strongly doubt if this problem has anything to do with Viewstate. It has more to do with Session state and Authentication cookies.

Is your application running on a Web farm/garden ? If so, you should take a look at this article.

If not, this error can commonly occur if your FormsAuthenticationTicket timeout is less than the Session Timeout. What happens is that the Auth ticket expires sooner than the user's session and the next request is unable to be authenticated.

JoshBerke

This looks like an authentication issue. You probally have a timeout set on the authentication ticket which is expiring. If you use a sliding timeout then every time you hit the server the ticket will be renewed. If you don't your tickets will expire and you'll need to handle this case.


Edit:

You can check out this support article to see if it applies to you.

Also you can check out this view state viewer might help you determine if the view state is invalid.

Here's another good post from a Microsoft Escalation Engineer

I also had this error....

If you look at the error, its likely your encrypted URL query string. What happens is the webresource.axd generated URL string has identities that were encrypted using the machinekey setting. These expire and if you have a page where you sit then try and submit using the encrypted string, the Event ID 1316 or 4009 is fired. You camn probably capture this exception in the Application_Error event and check whether the CryptographicException was fired.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!