视图状态 MAC 验证失败
我收到此异常帮助我如何解决此问题。
Error Time : 20091104 151412
Error Message : 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 : System.Web
StackTrace : at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
at System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState)
at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState)
at System.Web.UI.HiddenFieldPageStatePersister.Load()
at System.Web.UI.Page.LoadPageStateFromPersistenceMedium()
at System.Web.UI.Page.LoadAllState()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.bla_bls_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\87932190\f6393965\App_Web_slwxkxn3.2.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Target Site : Void ThrowError(System.Exception, System.String, System.String, Boolean)
Inner Exception : System.Web.UI.ViewStateException: Invalid viewstate.
Client IP: 172.16.153.71
Port: 1466
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 2.0.50727)
ViewState: /wEPDwUKLTg3MDIzOTc1Ng9kFgICAw9kFgICAw9kFgJmD2QWBgIdD2QWAgIBDzwrAA0BAA8WBB4LXyFEYXRhQm91bmRnHgtfIUl0ZW1Db3VudAIUZBYCZg9kFioCAQ9kFhpmDw8WAh4EVGV4dAUDODU4ZGQCAQ8PFgIfAgUKMSAgICAgICAgIGRkAgIPDxYCHwIFDE5ZS1UgNjEwOTc1MGRkAgMPDxYCHwIFAzQwJ2RkAgQPDxYCHwIFA05ZS2RkAgUPDxYCHwIFClgtUHJlc3MgMjFkZAIGDw8WAh8CBRQzMCBPY3QgMjAwOSAwNDowMDowMGRkAgcPDxYCHwIFB1RFTEZPUkRkZAIIDw8WAh8CBQJJS2RkAgkPDxYCHwIFAkZHZGQCCg8PFgQeCUJhY2tDb2xvcgqmAR4EXyFTQgIIZBYCAgEPDxYCHwIFCkluIFByb2Nlc3NkZAILDw8WBB8DCqcBHwQCCGQWAgIBDw8WAh8CBRQwNCBOb3YgMjAwOSAxMTowMDowMGRkAgwPZBYCAgEPDxYCHwIFBkV4ZmFjdGRkAgIPZBYaZg8PFgIfAgUDODU1ZGQCAQ8PFgIfAgUKMiAgICAgICAgIGRkAgIPDxYCHwIFDE5ZS1UgODQ0Mzc0NWRkAgMPDxYCHwIFAzQwJ2RkAgQPDxYCHwIFA05ZS2RkAgUPDxYCHwIFClgtUHJlc3MgMjFkZAIGDw8WAh8CBRQyOSBPY3QgMjAwOSAwMzozMDowMGRkAgcPDxYCHwIFB1RFTEZPUkRkZAIIDw8WAh8CBQJJS2RkAgkPDxYCHwIFAkZHZGQCCg8PFgQfAwqmAR8EAghkFgICAQ8PFgIfAgUKSW4gUHJvY2Vzc2RkAgsPDx... ---> System.Web.HttpException: Unable to validate data.
at System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
--- End of inner exception stack trace ---
i am getting this exception help me how to solve this problem.
Error Time : 20091104 151412
Error Message : 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 : System.Web
StackTrace : at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
at System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState)
at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState)
at System.Web.UI.HiddenFieldPageStatePersister.Load()
at System.Web.UI.Page.LoadPageStateFromPersistenceMedium()
at System.Web.UI.Page.LoadAllState()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.bla_bls_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\87932190\f6393965\App_Web_slwxkxn3.2.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Target Site : Void ThrowError(System.Exception, System.String, System.String, Boolean)
Inner Exception : System.Web.UI.ViewStateException: Invalid viewstate.
Client IP: 172.16.153.71
Port: 1466
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 2.0.50727)
ViewState: /wEPDwUKLTg3MDIzOTc1Ng9kFgICAw9kFgICAw9kFgJmD2QWBgIdD2QWAgIBDzwrAA0BAA8WBB4LXyFEYXRhQm91bmRnHgtfIUl0ZW1Db3VudAIUZBYCZg9kFioCAQ9kFhpmDw8WAh4EVGV4dAUDODU4ZGQCAQ8PFgIfAgUKMSAgICAgICAgIGRkAgIPDxYCHwIFDE5ZS1UgNjEwOTc1MGRkAgMPDxYCHwIFAzQwJ2RkAgQPDxYCHwIFA05ZS2RkAgUPDxYCHwIFClgtUHJlc3MgMjFkZAIGDw8WAh8CBRQzMCBPY3QgMjAwOSAwNDowMDowMGRkAgcPDxYCHwIFB1RFTEZPUkRkZAIIDw8WAh8CBQJJS2RkAgkPDxYCHwIFAkZHZGQCCg8PFgQeCUJhY2tDb2xvcgqmAR4EXyFTQgIIZBYCAgEPDxYCHwIFCkluIFByb2Nlc3NkZAILDw8WBB8DCqcBHwQCCGQWAgIBDw8WAh8CBRQwNCBOb3YgMjAwOSAxMTowMDowMGRkAgwPZBYCAgEPDxYCHwIFBkV4ZmFjdGRkAgIPZBYaZg8PFgIfAgUDODU1ZGQCAQ8PFgIfAgUKMiAgICAgICAgIGRkAgIPDxYCHwIFDE5ZS1UgODQ0Mzc0NWRkAgMPDxYCHwIFAzQwJ2RkAgQPDxYCHwIFA05ZS2RkAgUPDxYCHwIFClgtUHJlc3MgMjFkZAIGDw8WAh8CBRQyOSBPY3QgMjAwOSAwMzozMDowMGRkAgcPDxYCHwIFB1RFTEZPUkRkZAIIDw8WAh8CBQJJS2RkAgkPDxYCHwIFAkZHZGQCCg8PFgQfAwqmAR8EAghkFgICAQ8PFgIfAgUKSW4gUHJvY2Vzc2RkAgsPDx... ---> System.Web.HttpException: Unable to validate data.
at System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
--- End of inner exception stack trace ---
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的服务器作为集群的一部分运行(即对应用程序的请求在多个服务器之间平衡),则必须确保您的计算机全部配置为使用相同的计算机密钥。
发生回发时,ASP.NET 对 ViewState 数据执行验证。此验证使用私钥(机器密钥)来保证数据的完整性。如果您没有明确指定此密钥,则会为您生成该密钥。不同的机器将生成不同的密钥,因此负载平衡的请求可能会验证失败,因为它们根据首先提供页面的位置以及回发的位置来针对不同的密钥进行验证。
本文详细介绍了机器密钥的用途以及如何配置您的服务器。
If your server is running as part of a cluster (i.e. requests to your application are balanced across multiple servers), you must ensure that your machines are all configured to use the same machine key.
ASP.NET performs validation of ViewState data when a Postback occurs. This validation uses a private key (the Machine Key) to guarantee the integrity of the data. If you don't explicitly specify this key, it is generated for you. Different machines will generate different keys, and thus load-balanced requests may fail validation because they are validating against different keys depending on where the page is first served from and where the Postback is sent back.
This article tells you more about the purpose of machine keys as well as how to configure your servers.
您需要在所有服务器上的 web.config 中具有相同的验证密钥。
您可以借助此网站生成密钥
You need to have the same validation keys inside your web.config on all server.
You can generate the keys with the help of this site
另请检查您的 IIS。在连接部分中,显示应用程序池列表,选择所需的池并转到“回收...”工具菜单。
确保分配了足够的内存。要查看这一情况,请在安装了 IIS 的计算机上的任务管理器中观察 w3wp.exe 进程使用的内存量。
正确设置回收管理器属性。
我放弃了“虚拟内存使用”复选框,并更愿意为回收池应用程序规划指定的时间。
Please also check your IIS. In the connections section, Display Applications pools list, choose the expected pool and go to 'Recycle...' tool menu.
Make sure that enough memory is allocated. To see that, watch the w3wp.exe process used amount of memory within the task manager on the machine where IIS is installed.
Set up properly the Recycling manager properties.
I discarded 'Virtual memory use' checkbox and prefered to plan specified hours for recycling pool application.