Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Background: I developed a web app in ASP.Net 3.5 in C#. It runs great but now a few users have reported that they recieve an error sometimes. I have tried to duplicate the error but it has been hard. One time though when I let the app sit I came back later and tried to move it along and it errored out. I would think that has something to do with the timeout but I am using the view state.

Any ideas? When I look at the eventLog I do see the following error entry.

Thank You for your help and ideas!

John


My event log has the following errors:

Event code: 4005

Event message: Forms authentication failed for the request. Reason: The ticket supplied has expired.

Event time: 14/03/2008 13:19:26

Event time (UTC): 14/03/2008 13:19:26

Event ID: d9f0333c2eed46e0b0207da69d2ea70e

Event sequence: 154

Event occurrence: 5

Event detail code: 50202


Event code: 3005

Event message: An unhandled exception has occurred.

Event time: 3/12/2009 7:49:59 AM

Event time (UTC): 3/12/2009 11:49:59 AM

Event ID: 590ac0f6ad734d988e9e02f0fb7800eb

Event sequence: 52

Event occurrence: 1

Event detail code: 0

Application information:

Application domain: /LM/W3SVC/32/ROOT-1-128813294498061103 

Trust level: Full 

Application Virtual Path: / 

Application Path: C:\Home\LocalUser\ucpga\Web\ 

Machine name: 169349-WEB2 

Process information:

Process ID: 6912 

Process name: w3wp.exe 

Account name: NT AUTHORITY\NETWORK SERVICE 

Here is the latest error:

Event code: 4009 Event message: Viewstate verification failed. Reason: The viewstate supplied failed integrity check. Event time: 3/15/2009 10:26:27 PM Event time (UTC): 3/16/2009 2:26:27 AM Event ID: 3b5be134005e49c3b40400bcaa5cb48d Event sequence: 56 Event occurrence: 1 Event detail code: 50203

Application information: Application domain: /LM/W3SVC/32/ROOT-1-128816433841748972 Trust level: Full Application Virtual Path: / Application Path: C:\Home\LocalUser\ucpga\Web\ Machine name: 169349-WEB2

Process information: Process ID: 8892 Process name: w3wp.exe Account name: NT AUTHORITY\NETWORK SERVICE

Request information: Request URL: https://hr.ucpga.org:443/application.aspx Request path: /application.aspx User host address: 74.160.64.222 User:
Is authenticated: False Authentication Type:
Thread account name: 169349-WEB2\ucpga

ViewStateException information: Exception message: Invalid viewstate. Client IP: 74.160.64.222 Port: 1251 User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB5; .NET CLR 1.1.4322; InfoPath.1)

like image 966
JPJedi Avatar asked Mar 16 '09 13:03

JPJedi


2 Answers

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)

like image 134
Kev Avatar answered Sep 27 '22 17:09

Kev


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.

like image 29
Cerebrus Avatar answered Sep 27 '22 19:09

Cerebrus