Validation of viewstate MAC failed in ASP.NET 4.0 with URL Routing

dollo2night

New Member
I am getting the notorious error of\[code\]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.\[/code\]After extensive searching, I cannot find anything that solves my particular issue. I am using URL Routing in .NET 4, but I am NOT using MVC. All of the problems/solutions I have found that are similar (due to the URL routing) provide solutions in MVC, but not in regular ASP.NET Web Forms.The Stack Overflow question here notes:\[quote\] It seems to be related to the number of sub-paths in the url. If there are at least 2 sub-paths the viewstate validation fails.\[/quote\]In testing this theory, I was able to provide a quick and dirty work-around by simply changing my route from \[code\]Module/Search/Results \[/code\]to \[code\]Module/SearchResults \[/code\]which has temporarily solved the issue, however, none of the answers in that post helped at all.Something interesting I found, the error can be reproduced in IE9, but not in Chrome 24.0.1313.52m. This lead me to believe that this error is browser specific so I tried setting NoCache for my site, but to no avail, Chrome still worked and IE9 still threw the ViewState error.In order to reproduce the problem, here are some key factors to my environment:\[code\]Windows 7 64-bitIIS 6.1 SP 1Local Web Project (VS 2010)Nested Master Pages (3 levels)URL Routing (defined in Global.asax)Page contains a GridView with a TemplateField. GridView has PagerSettings defined.Links causing the error are within the TemplateField.Links outside of the GridView do not cause the error.\[/code\]The steps to reproduce are as follows:\[code\]User browses to page "~/Module/Search/Results" (from link or directly doesn't matter)User clicks on a button that posts back and causes a redirect to another page "~/Module/DoSomething"User presses the Back button in the browser which takes them back to "~/Module/Search/Results"User then proceeds to press a button that causes a post-back which immediately causes the error.\[/code\]\[quote\] UPDATE: Added information in the key factors regarding the layout of the page.\[/quote\]How can I solve this issue for all browsers so that I can have 2 or more sub-paths in the URL of a web page without causing the error when the user comes back to the page and then generates another post back?
 
Back
Top