gpt4 book ai didi

c# - asp.net Base-64 字符串中的无效字符

转载 作者:行者123 更新时间:2023-11-30 17:23:56 26 4
gpt4 key购买 nike

我有一个 C# 移动站点,但在使用某些移动客户端时遇到了问题。我在下面发布了一个跟踪,但基本上电话浏览器或手机连接到互联网 url 的 wap 网关对表单中的 View 状态隐藏输入进行编码。

/wEPDwULLTExNTMyOTcwOTBkGAEFBlBtTGlzdA9nZA==

成为

%2FwEPDwULLTExNTMyOTcwOTBkGAEFBlBtTGlzdA9nZA%3D%3D

因此 View 状态失败。

有没有办法在处理之前覆盖和 urldecode viewstate 信息?

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 对象。您可能想从 HiddenFieldPageStatePersister 派生它.看看this article它显示了如何在 ViewState 之上实现压缩,但与您需要执行的操作非常相似。

这里涉及到一些技巧:您需要使用反射来设置 StateFormatter 的字段基类,与MSDN docs相反比如说,没有被标记为虚拟的,所以没有反射就不能被覆盖。

关于c# - asp.net Base-64 字符串中的无效字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1580399/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com