从现在开始,我第一次在开始调试我的MVC应用程序时收到这个错误
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.
全堆栈跟踪
[ViewStateException: Invalid viewstate. Client IP: 127.0.0.1 Port: Referer: Path: /Login/logon User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.7 (KHTML,like Gecko) Chrome/7.0.517.41 Safari/534.7 ViewState: Fvq7WNUu+qCC00VbTIOTUuBvK4YHjxp3RubwsrFYW93hKlF7I4GLzaNHceRqjjJB0GwvRPWwlwE6brhAZAo+Mp191B/C+l8Dw/w7aQBDCpWGC3ox6hkSeZp10vbjm9eJFQZmGSPyC1rKYwApBBaz0Q==] [HttpException (0x80004005): 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.] System.Web.UI.ViewStateException.ThrowError(Exception inner,String persistedState,String errorPageMessage,Boolean macValidationError) +198 System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner,String persistedState) +14 System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +274 System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4 System.Web.Mvc.AntiForgeryDataSerializer.Deserialize(String serializedToken) +176
这是什么意思?
请注意:错误仅在调试期间发生.当我在本地IIS部署应用程序时,一切正常.它显示在我的母版页面的以下代码中
<form id="__AjaxAntiForgeryForm" action="#" method="post"> <%= Html.AntiForgeryToken() %> </form>