如何使用 ScriptManager.GetStateString()?
根据 MSDN 文档, ScriptManager.GetStateString()
“检索包含表示网页状态的键/值对的字符串。”
当我调用该方法时,它返回的内容看起来是散列字符串 - 如何将其解析为有用的内容? GetStateString
方法到底返回什么?
编辑: 我注意到,如果我在页面上提交表单或将数据附加到查询字符串,GetStateString
返回的值不会更改。 “页面状态”显然不包括这种状态数据?
更新:当我设置ScriptManager.EnableSecureHistoryState = false
时,哈希值将替换为空字符串。显然,如果 EnableSecureHistoryState = true,则 GetStateString 返回的值将被加密和散列。
According to the MSDN documentation, ScriptManager.GetStateString()
"Retrieves a string that contains key/value pairs that represent the state of the Web page."
When I call the method it returns what appears to be a hashed string - how do I parse this into something useful? What exactly is returned by the GetStateString
method?
EDIT:
I notice that if I submit the form on the page or append data to the querystring, the value returned by GetStateString
does not change. "Page state" apparently doesn't include this sort of state data?
UPDATE: When I set ScriptManager.EnableSecureHistoryState = false
the hashed value is replaced with an empty string. Apparently if EnableSecureHistoryState = true, the value returned by GetStateString is encrypted and hashed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GetStateString()
从历史哈希中返回状态。历史哈希是您在 Ajax 应用程序中启用浏览器后退/前进按钮的答案。它会记录您的输入,以便您可以前后移动。
查看 AddHistoryPoint 方法将数据添加到历史哈希并检查此 博客文章 例如用法。
当 ScriptManager.EnableSecureHistoryState = true 时获得哈希响应的原因是历史状态哈希表为空,但不为 NULL。它是一个仍然可以序列化和加密的对象。
如果状态哈希为 NULL 或空,则将返回一个空字符串,我怀疑这就是您的情况。您尚未添加历史记录点。
GetStateString()
returns the state from the history hash.The history hash is your answer to enable the browser back/forward buttons in your Ajax application. It records your entries so you can go back and forward.
Check out the AddHistoryPoint method for adding data to the history hash and check this blog post for example usage.
The reason you get a hashed response when
ScriptManager.EnableSecureHistoryState = true
is because the history state hash table is empty, but not NULL. It is an object which can still be serialized and encrypted.If the state hash is NULL or empty, an empty string will be returned, and I suspect this to be your case. You haven't added a history point.