验证视图状态 MAC 失败解决方法
2014-02-17 15:42
225 查看
验证视图状态 MAC 失败。如果此应用程序由网络场或群集承载,请确保 <machineKey> 配置指定了相同的 validationKey 和验证算法。不能在群集中使用
AutoGenerate。
运行时提示错误:
验证视图状态 MAC 失败。如果此应用程序由网络场或群集承载,请确保 <machineKey> 配置指定了相同的 validationKey 和
验证算法。不能在群集中使用 AutoGenerate。
StackTrace: 在 System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState,
String errorPageMessage, Boolean macValidationError)
在 System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
在 System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState)
在 System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState)
在 System.Web.UI.HiddenFieldPageStatePersister.Load()
在 System.Web.UI.Page.LoadPageStateFromPersistenceMedium()
在 System.Web.UI.Page.LoadAllState()
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
在 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
在 System.Web.UI.Page.ProcessRequest()
在 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
在 System.Web.UI.Page.ProcessRequest(HttpContext context)
在 ASP.pcpf_login_login_aspx.ProcessRequest(HttpContext context) 位置
d:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NETFiles\famsweb\d5e90b06\537ccf9e\App_Web_login.aspx.d2f46862.6plrloiq.0.cs:行号 0
在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
解决方案:
在web.config里配置
在<system.web>下添加<pages enableViewStateMac="false"></pages>
查下MSDN就明白了,validationKey和decryptionKey的默认值是AutoGenerate,由系统随机生成密钥,如果在本地或者使用的
是独立主机通常不会有什么问题,但是使用虚拟主机,一台服务器上有多个虚拟主机存在时就会出现以上问题,MSDN中也特别指出不能在群集中使用 AutoGenerate应该指定固定的密钥值,至此真相水落石出,立刻在web.config中添加关于machineKey的配置项,并手动设置其中的密钥值,这里请注意,不同加密算法对于密钥的最大字符长度是不同的,在这里能够使用的有AES,DES,3DES,SHA1,MD5,我只知道DES的密钥字符长度为16,3DES长度为48,手动设置时密钥长度必须等于其最大长度,否则会出错!至于密钥的16进制值可以随便输入。
AutoGenerate。
运行时提示错误:
验证视图状态 MAC 失败。如果此应用程序由网络场或群集承载,请确保 <machineKey> 配置指定了相同的 validationKey 和
验证算法。不能在群集中使用 AutoGenerate。
StackTrace: 在 System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState,
String errorPageMessage, Boolean macValidationError)
在 System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
在 System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState)
在 System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState)
在 System.Web.UI.HiddenFieldPageStatePersister.Load()
在 System.Web.UI.Page.LoadPageStateFromPersistenceMedium()
在 System.Web.UI.Page.LoadAllState()
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
在 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
在 System.Web.UI.Page.ProcessRequest()
在 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
在 System.Web.UI.Page.ProcessRequest(HttpContext context)
在 ASP.pcpf_login_login_aspx.ProcessRequest(HttpContext context) 位置
d:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NETFiles\famsweb\d5e90b06\537ccf9e\App_Web_login.aspx.d2f46862.6plrloiq.0.cs:行号 0
在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
解决方案:
在web.config里配置
在<system.web>下添加<pages enableViewStateMac="false"></pages>
查下MSDN就明白了,validationKey和decryptionKey的默认值是AutoGenerate,由系统随机生成密钥,如果在本地或者使用的
是独立主机通常不会有什么问题,但是使用虚拟主机,一台服务器上有多个虚拟主机存在时就会出现以上问题,MSDN中也特别指出不能在群集中使用 AutoGenerate应该指定固定的密钥值,至此真相水落石出,立刻在web.config中添加关于machineKey的配置项,并手动设置其中的密钥值,这里请注意,不同加密算法对于密钥的最大字符长度是不同的,在这里能够使用的有AES,DES,3DES,SHA1,MD5,我只知道DES的密钥字符长度为16,3DES长度为48,手动设置时密钥长度必须等于其最大长度,否则会出错!至于密钥的16进制值可以随便输入。
相关文章推荐
- 验证视图状态 MAC 失败,解决方法
- 验证视图状态 MAC 失败,从客户端检测到有潜在危险的Request.Form值的解决方法
- 验证视图状态 MAC 失败解决方法
- 关于“验证视图状态 MAC 失败。如果此应用程序由网络场或群集承...”错误的解决方法
- 验证视图状态MAC 失败。如果此应用程序由网络场或群集承..——解决方法
- 验证视图状态 MAC 失败解决方法
- 验证视图状态 MAC 失败,解决方法
- 关于“验证视图状态 MAC 失败”的解决方法
- 验证视图状态MAC失败的解决办法
- ASP.NET Post页面及验证视图状态MAC失败问题的正确解决办法
- 通过machineKey配置解决asp.net验证视图状态MAC失败的问题
- 验证视图状态 MAC 失败。如果此应用程序由网络场或群集承载,请确保 配置指定了相同的 validationKey 和验证算法。不能在群集中使用 AutoGenerate 的解决办法
- ASP.NET Post页面及验证视图状态MAC失败问题的正确解决办法
- 验证视图状态 MAC 失败 的解决办法
- 验证视图状态 MAC 失败的解决办法
- 页面及验证视图状态MAC失败问题正确的解决办法
- 验证视图状态 MAC 失败的解决办法
- ASP.NET视图状态验证MAC失败 解决办法
- 验证视图状态 MAC 失败的解决办法
- 待解决问题:验证视图状态 MAC 失败。如果此应用程序由网络场或群集承载,请确保 <machineKey> 配置指定了相同的 validationKey 和验证算法。不能在群集中使用 AutoGenerate