We are using ASP.NET MVC for the majority of our new web application projects and came across an issue when using a MVC View User Control (actually it happens with MVC View page too) which contained some common javascript and html elements required on multiple pages.
The MVC View Page itself used Html.RenderPartial to render the MVC View User Control and the initial load worked fine. It was however an Edit Page and when the validation failed we received the following 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."
This has been discussed
here and
here amongst other places and it did in fact seem like removing the form tag from our Master Page solved the problem (Tried removing the form tag from the View Page, but this had no change on the error). This was however not the best solution as it meant changing many of the Pages which did not have their own form tags, but did have controls which required them.
We've now gone with using ViewUserControlWithoutViewState class created by Mauricio Scheffer which can be found
here.