我有一个 C# 移动网站,并且在使用某些移动客户端时遇到问题。我在下面发布了一条跟踪,但基本上是手机浏览器或手机连接到互联网 url 的 wap 网关对表单中的视图状态隐藏输入进行编码。
/wEPDwULLTExNTMyOTcwOTBkGAEFBlBtTGlzdA9nZA==
becomes
%2FwEPDwULLTEXNTMyOTcwOTBkGAEFBlBtTGlzdA9nZA%3D%3D
所以视图状态失败。
在处理之前是否有重写和 url 解码视图状态信息?
System.Web.HttpException: The state information is invalid for this page and might be corrupted. ---> System.Web.UI.ViewStateException: Invalid viewstate.
Client IP: 65.91.116.34
Port: 37172
User-Agent: SCH-R430 UP.Browser/6.2.3.8 (GUI) MMP/2.0
ViewState: %2FwEPDwULLTExNTMyOTcwOTBkGAEFBlBtTGlzdA9nZA%3D%3D
Referer:
Path: /mobile/Inbox.aspx ---> System.FormatException: Invalid character in a Base-64 string.
at System.Convert.FromBase64String(String s)
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()
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
at System.Web.UI.ViewStateException.ThrowViewStateError(Exception inner, String persistedState)
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.mobile_inbox_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
您可以实现一个自定义 ViewStatePersister 对象来处理此问题。您可能想从中导出它隐藏字段页面状态持久化 http://msdn.microsoft.com/en-us/library/system.web.ui.hiddenfieldpagestatepersister.aspx。看一眼本文 http://aspadvice.com/blogs/mamanzes_blog/archive/2006/08/27/Save-some-space_2C00_-compress-that-ViewState.aspx它展示了如何在 ViewState 之上实现压缩,但与您需要做的非常相似。
这涉及到一些黑客行为:您需要使用反射来设置状态格式化程序 http://msdn.microsoft.com/en-us/library/system.web.ui.pagestatepersister.stateformatter.aspx基类,与MSDN 文档 http://msdn.microsoft.com/en-us/library/system.web.ui.pagestatepersister.stateformatter.aspx也就是说,没有标记为虚拟,因此不能在没有反射的情况下被覆盖。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)