asp.net - View 状态 MAC 验证失败

标签 asp.net viewstate

这个问题在这里已经有了答案:




8年前关闭。




Possible Duplicate:
Setting ViewStateUserKey gives me a “Validation of viewstate MAC failed” error



我已经应用了 StackOverflow 上帖子的解决方案,但它们并没有解决我的问题。

问题的详细信息是:
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.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: 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.

[HttpException (0x80004005): Unable to validate data.]
   System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +10986325
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +295

[ViewStateException: Invalid viewstate. 
    Client IP: 131.155.68.60
    Port: 53999
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16
    ViewState: /wEPDwULLTIxNDQxNzQ5ODlkZDYHBedPRvEzZrTTrJvp9yAr5yfa
    Referer: http://rms.rextron.eu/login.aspx?ReturnUrl=%2fdefault.aspx
    Path: /login.aspx]

[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) +148
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +10959605
   System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +59
   System.Web.UI.HiddenFieldPageStatePersister.Load() +10959704
   System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +11043464
   System.Web.UI.Page.LoadAllState() +46
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11038983
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11038522
   System.Web.UI.Page.ProcessRequest() +91
   System.Web.UI.Page.ProcessRequest(HttpContext context) +240
   ASP.login_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\9ec5a6be\294c12de\App_Web_ptjxac-a.1.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

我已经尝试将其放在 web.config 中:
<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never">

最佳答案

不久前我问了一个类似的问题。你有吗see this post ?帮助我解决此错误的另一件事是设置 machineKey .看到这个 Microsoft Page about the problem and setting a Machine Key .

关于asp.net - View 状态 MAC 验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5647525/

相关文章:

c# - 在 ViewState 中存储数据表

asp.net vnext。 mvc 6.实现简单的自己授权

asp.net - 发送电子邮件,但不是现在

c# - 如何将 CssStyleCollection 用于 UserControl?

javascript - 颜色框和 ListView

asp.net - View 状态会过期吗?

viewstate - 无效 View 状态错误

asp.net - 为什么我的 @page enableviewstate 没有覆盖 web.config 中页面的 EnableViewstate?

asp.net - 从母版页 asp.net 访问控件 - 存储值

javascript - 如何让 Javascript 中的 wait 1 方法完成其他方法