任何人都可以帮我解决这个例外.我尝试了几个修复,但没有任何效果.我只在IE(7,8和9)中获得此异常.
当我第一次加载页面时,它会显示一个下拉列表.我选择一个特定的供应商,它会发回一个页面并返回所需的信息.如果我更改供应商,它仍将加载信息.当我使用$.ajax请求动态地将控件加载到页面上,然后返回并更改下拉列表选择(选择其他供应商)时,它会疯弃并给出以下异常.它再次发生在IE中.
The state information is invalid for this page and might be corrupted. 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: The state information is invalid for this page and might be corrupted. Source Error: [No relevant source lines] Source File: c:\Users\tmalik\AppData\Local\Temp\Temporary ASP.NET Files\root\6691c708\751e6443\App_Web_a3kdfsht.2.cs Line: 0 Stack Trace: [FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character,more than two padding characters,or a non-white space character among the padding characters. ] System.Convert.FromBase64String(String s) +0 System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +77 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() +147 [ViewStateException: Invalid viewstate. Client IP: 127.0.0.1 Port: Referer: http://localhost:57289/vendor.aspx Path: /vendor.aspx User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; MDDR) ViewState: 2D1IMRanPXfVARbRp1ooiwD71WHybNzxSNLbbA0G3MxKeo7m52dHWLBPGdnMH5JthTnPVt7UES/PVx39dfZYHbr0/DL7J58mvA2I4wRUSdDShVxvZqC7ZPZWcatowpZ7VYaD9PFKW7OkgppCwmePFuYnpU8kWDT5TvSLqN50Flrqpv0zCM9YoCKemfesa68rqBkkSTijcxnxdDCgvzSl72giI4ZhwK92wD22Ma6scW4PFjRZeTsKoowJq+JqJGuBMEepwKguFUy4dX86UIULnJ7NQsgZW1aQvpZdnfSRCSYrWhFWPhKTPsS622eaQYShsxddPs/mfEB26f54WS+iBYuk3mWm8jr6sWvsOIRtwH8b3E/5UujbgAxTNVg8BhzpSFvmE4KwGKo0tKuuqOFtP0pjpaAI7fV3EQ1M7BVQSAVrtBevRFJ0PlCPrU2aQms2LVeE5POqTJGtY+74xWkdCtLzT04Ug4R+SMBRElQBqX/5A54OHj2ghYjJ/3tgg4ToGUX2xrQ/c70lrPHP+kabGVM2Op4DFjZAaOZj/CDVUurH2BYXKuJdUvzbf2zHngoOnqZGqrw3n6V6HGcnHNKxfuGQ20MPdxJYCbYHGiRqixzV1NxJoHFHbYCVx3IlrqF0W44AFKm2gzzk3V8zu9lUjyFNvUNBMjNaZeekLtcWpszhKrm8WhVnWQAk1CXxKJqyK0RC3...] [HttpException (0x80004005): The state information is invalid for this page and might be corrupted.] System.Web.UI.ViewStateException.ThrowError(Exception inner,String persistedState,String errorPageMessage,Boolean macValidationError) +235 System.Web.UI.ViewStateException.ThrowViewStateError(Exception inner,String persistedState) +14 System.Web.UI.HiddenFieldPageStatePersister.Load() +251 System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +106 System.Web.UI.Page.LoadAllState() +43 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) +8431 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) +253 System.Web.UI.Page.ProcessRequest() +78 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21 System.Web.UI.Page.ProcessRequest(HttpContext context) +49 ASP.vendor_aspx.ProcessRequest(HttpContext context) in c:\Users\tmalik\AppData\Local\Temp\Temporary ASP.NET Files\root\6691c708\751e6443\App_Web_a3kdfsht.2.cs:0 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously) +75
解决方法
好的,所以这里是我提出的解决方案/黑客.我的问题是在页面上动态添加用户控件(通过ajax请求)正在改变页面的视图状态并抛出异常.经过研究,我发现viewstate存储了页面的状态(属性和设置).一旦从Web服务返回控件html,就会有某种视图状态存储在页面上.当您回发到服务器时,它会在解密视图以重建页面时抛出异常.我只是使用jquery删除了那些在页面上发布的控件(动态添加)并且问题得到了解决.
//In my case "VendorListDropDownSearchable",causes the page post back. $("#VendorListDropDownSearchable").change( function () { $("#UserControl1DIV").remove(); //removing the place holder holding control1 $("#UserControl2DIV").remove(); //same as above });