当前位置:  开发笔记 > 编程语言 > 正文

使用ASP.NET和C#"Base-64字符串中的无效字符"

如何解决《使用ASP.NET和C#"Base-64字符串中的无效字符"》经验,为你挑选了1个好方法。

我在发布页面时遇到此问题.该页面有一个jquery ajax加载,由下拉列表的onchange调用,如果我禁用onchange,帖子工作.

"状态信息对此页面无效,可能已损坏"

[FormatException: Invalid character in a Base-64 string.]
   System.Convert.FromBase64String(String s) +0
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +72
   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() +113

[ViewStateException: invalid Viewstate. 
         Client IP: 127.0.0.1
         Port: 
         User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
         ViewState: /wEPDwULLTE1NjAwNjAwNDMPZBYCZg9kFgRmD2QWAgIOD2QWCAIBDxYCHgRUZXh0BSpTcGVyaW5kZSBJbcOzdmVpcyAmcnNhcXVvOyBQw6FnaW5hIEluaWNpYWxkAgMPFgIfAAUOdmVuZGFyLCBhbHVnYXJkAgUPFgIfAGVkAgcPFgIfAAUaaHR0cDovL3d3dy5zcGVyaW5kZS5jb20uYnJkAgEPZBYQAgMPEGQQFQEPVGlwbyBkZSBJbcOzdmVsFQEAFCsDAWdkZAIEDxBkEBUBBkNpZGFkZRUBABQrAwFnZGQCBg8QZA8WAWYWARAFD1RpcG8gZGUgSW3Ds3ZlbGVnZGQCBw8QD2QWAh4Ib25jaGFuZ2UFGSQuY2hhbmdlQ2l0eSh0aGlzLnZhbHVlKTsPFgFmFgEQBQZDaWRhZGVlZ2RkAggPZBYQAgEPFgIfAAUMTE9GVCBWSVNDQVlBZAIDDxYCHwAFKUNhc2EgMyBkb3JtaXTDs3Jpb3Mgbm8gYmFpcnJvIEJlbGEgVmlzdGEuZAIHDxYCHwAFHjxzdHJvbmc+UiQgMjUwLjAwMCwwMDwvc3Ryb25nPmQCCQ8WAh8ABRUxNTYwLjQ0IG08c3VwPjI8L3N1cD5kAgsPFgIfAAUJMyBlIDQgIEQuZAINDw8WBh8ABRBFeGNsdWlyIGRhIGxpc3RhHgdUb29sVGlwBRBFeGNsdWlyIGRhIGxpc3RhHgtOYXZpZ2F0ZVVybAUUI3JlbW92ZUxpbmsgMjEwMDM3NzlkZAIPDw8WBh8DBUB+L3ZlbmRhL2xhbmNhbWVudG...]

[HttpException (0x80004005): As informações sobre estado são inválidas para esta página e podem estar corrompidas.]
   System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +106
   System.Web.UI.ViewStateException.ThrowViewStateError(Exception inner, String persistedState) +14
   System.Web.UI.HiddenFieldPageStatePersister.Load() +217
   System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +105
   System.Web.UI.Page.LoadAllState() +43
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
   System.Web.UI.Page.ProcessRequest() +80
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.content_search_default_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\web-site-2009\e4bfc9d6\d5d6c855\App_Web_zcb1qfmu.0.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

可能是什么原因?以前有人见过吗?

谢谢

编辑:

所以,我发现了为什么会这样.在Page_Load的末尾,我编写了一个调用jquery函数的javascript行,该函数将新字段加载到div中.所以,正如我所看到的,这导致在viewstate上产生不一致.对于这种情况,禁用ViewState不是一个选项.它适用于FF,它在IE上有问题.任何人?

谢谢



1> 小智..:

刚碰到这个.从您通过jquery加载的页面中删除表单标记.

推荐阅读
路人甲
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有