question

78669366 avatar image
0 Votes"
78669366 asked AgaveJoe edited

Invalid viewstate

Hi

I am getting below on my webform;

 Exception Type: System.Web.HttpException
 Exception: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

At present it seems the problem only seems to effect iPhone. This webform is being redirected to from our main non asp.net site from Wix. The suspicion is that safari on iPhone is getting confused regarding view state during redirect.

Has anyone come across this and has a solution?

Thanks

Regards

dotnet-aspnet-webforms
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Has anyone come across this and has a solution?

Yes. This is a well documented error in web forms. ViewState is an input field encrypted by the local machine key. Typically what happens is the machine key changes between post backs which invalids the ViewState. The solution is to set a specific machine key as recommended in the error message.

Google Search: Validation of viewstate MAC failed


0 Votes 0 ·

Hi

We have the following in web.config but that has not helped.

   <system.web>

     <machineKey validationKey="<snipped>" decryptionKey="<snipped>" validation="SHA1" decryption="AES" />

   </system.web>

Regards

0 Votes 0 ·

The suspicion is that safari on iPhone is getting confused regarding view state during redirect.

ViewState is a hidden input field within the web form that maintains the state of user entries between post back. A redirect does not pass HTML form fields which includes the ViewState hidden field. Secondly, the first time a web form loads, ViewState is empty because the user has not entered any values. Keep in mind, this happens on the server. My best guess is the page in question is cached by the Safari browser. The cached page has a ViewState that was encrypted by a machine key that no longer exists. Try clearing the browser cache.

You might try Safari support too.



0 Votes 0 ·

0 Answers