.NET_Validation of viewstate MAC failed的解决办法

最近在系统运行过程中,发现某个页面只要不操作一段时候,再点击GridView的分页按钮,就会报错跳转,开放错误后得到以下页面提示~~

 

Server Error in '/' Application.

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.

Source Error:

[No relevant source lines]


Source File: c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/32db863b/3bbac91f/App_Web_ll8ji4tr.1.cs    Line: 0

Stack Trace:

[CryptographicException: Padding is invalid and cannot be removed.]
   System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) +1545747
   System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) +257
   System.Security.Cryptography.CryptoStream.FlushFinalBlock() +30
   System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Boolean useValidationSymAlgo) +164
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +147

[ViewStateException: Invalid viewstate. 
	Client IP: 10.10.130.100
	Port: 1728
	User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MyIE2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
	ViewState: 506fkWeEy9To98YjFEEzu11K9siwdmq1lSNPQfE7femx+NFkMdBXE0oA3R4oDdMiry2YtkX5wArrT2zCpnJN2Cyw3S7U8XKkPHFUjOYVExQ7CDLh9xUeVtOOEGGalxY9rspp5PV5dyk0bTHezFofRlqQ85e7soCkVlaR8mzS3526yUkfgjYSTgEutwM0tSLz8qiC+g6q8f0JuQ6ZxhxWqoJZXpjNF04l9aWzBxs3cx2m/w3ZIunceX7l1VRmhyp0GzpApR594zaYfNVFmEje+mM8IIPMINUqYi9z8qjbHk9LelP2nrwVbhCORXvV99pzF4ZK3lJcPpo6UoelJBAYhqklVJQHoNGyN9tpoi7NKtTNvTpnaaFNqvHzTj4VSagMaYFTJEkg3XbrjDd3EAjHv1chaAcaOYcas2biabmYSfZhczAANH823PMj6QiJijiyCoud9i66XgT/aBb1DI3kGYpApVEnDOnr6HHdfF5xA4Ec34SN7+/7EgUMJbbWhtdmFa2p4edI1ziBIW2UwxC2UGKIMpzs+jzER2TEBmJplhV38ou7EDLW9b2r43nWMg22ytHAGM4Ppx1UHpw9NlbxicqyKoM6k6QcR9mzs+b3ST7Gdwtuy+jO1T9VzxksYg5dY4YoduuDJZ2AFmEZEP06p9DFLM7Pcl6U2vPESQUA+C//y0GuO0y9mg9ZmHmbhQmZxd8X2XcQCgwWZcUrZf3pVIdtvk9Xqr7CPO0y3Wi7cSxqAsA8P1qnBgpUyD4+PgZDO3T5H9BOR51fiFSxjMuYT4o//tznxSOJrzIVXbl...]

[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) +267
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +282
   System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
   System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
   System.Web.UI.HiddenFieldPageStatePersister.Load() +198
   System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +83
   System.Web.UI.Page.LoadAllState() +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
   System.Web.UI.Page.ProcessRequest() +86
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.faqadmin_admindefault_aspx.ProcessRequest(HttpContext context) in c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/32db863b/3bbac91f/App_Web_ll8ji4tr.1.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

 

 

 

搜索后,发现可能是由于我们两台服务器,停留一段时间后,DNS解释到了另外一台的服务器,所以报错~~

 

找到两个解决的办法

1、处理页面增加

<%@ Page Language="C#"  enableViewStateMac="false" %>

 


2、Web.Config 加上以下代码(位置为 <system.web>...</system.web>内
<machineKey validationKey="B8CEF0C74E23E7197FCC4C9E3617C0007D94D43C7F7A79C582C54B95D69B946DFD49CAF5AA72F9A8CA2CBA040A9DF64DC1DF90DAE1214AE4F1AB7FA56DD65C0D" decryptionKey="D7F1CE31847C4FB31EF51E14F3820D52B659AF8523FC932C03506CC075DB8B28" validation="SHA1" decryption="AES" />

 

我使用了第二种方法,目前正在观察效果·~

 

 

 

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值