Friday, November 21, 2014

Validation of viewstate MAC failed when posting from one aspx file to another (cross posting asp.net forms)

The error
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.


We have a aspx form that posts to another form. This was done by changing form action for the first form to point to the second form. When this happens, asp.net was giving the above error.

As a solution, the submit button on the form was also changed to update the postbackURL to point to the second aspx page. So essentially, the form action and also the submit button postback URL were both pointed to the second aspz page where the form data is submitted!

Example:
this.Form.Action = "MyPage2.aspx";
SubmitButtonCtl.PostBackUrl = "MyPage2.aspx";

No comments:

Turn on Windows 11 Fast Boot

If windows starting is slow, to enable windows 11 fast startup/boot,  Press Windows + R, type powercfg.cpl, and hit Enter.  This will direct...