none
Validation of viewstate MAC failed

    Question

  • In a sharepoint 2010 page, I added two different custom Web Part that we developped.

    I am getting this error when I submit the custom properties form :

    System.Web.HttpException: 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.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [ViewStateException: Invalid viewstate. 
    	Client IP: ::1
    	Port: 50786
    	User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0

    ...

    Any idea how to prevent this ?



    Ala

    Thursday, March 22, 2012 4:32 PM

Answers

  • This problem and its work-arounds are related in some articles :

    http://forums.asp.net/p/955145/1173230.aspx

    https://connect.microsoft.com/VisualStudio/feedback/details/101988/validation-of-viewstate-mac-failed-when-posting-too-quickly

    http://elliottnash.com/post/Validation-of-viewstate-MAC-failed.aspx

    I removed the property DataKeyNames in the gridViews included in the Web Part. I don't have the error anymore.


    Ala

    • Marked as answer by Zino_o Monday, March 26, 2012 2:06 PM
    Monday, March 26, 2012 2:05 PM

All replies

  • Hi ,

    You can try to add enableViewStateMac=false on your page in the <page> tag  .You can open the page in SharePoint Designer .Open
    code view ,then add the enableViewStateView= false in <% Page language=”c#”….%>

    Thanks


    Entan Ming

    TechNet Community Support

    Monday, March 26, 2012 7:49 AM
  • Adding enableViewStateView= false doesn't work.

    The error occurs when I submit a custom propertie included in a ToolPart class that I developped. The property in cause is a PeopleEditor.

    In this PeopleEditor, if I submit an empty field, there is no error. But if I select an existing user then submit the form, I have the error : System.Web.HttpException: Validation of viewstate MAC failed...


    Ala

    Monday, March 26, 2012 8:33 AM
  • This problem and its work-arounds are related in some articles :

    http://forums.asp.net/p/955145/1173230.aspx

    https://connect.microsoft.com/VisualStudio/feedback/details/101988/validation-of-viewstate-mac-failed-when-posting-too-quickly

    http://elliottnash.com/post/Validation-of-viewstate-MAC-failed.aspx

    I removed the property DataKeyNames in the gridViews included in the Web Part. I don't have the error anymore.


    Ala

    • Marked as answer by Zino_o Monday, March 26, 2012 2:06 PM
    Monday, March 26, 2012 2:05 PM