我想了解 View 源中viewsate["x"] 和 __viewstate 之间的区别
即
在查看源页面中,隐藏控件中有 View 状态,例如:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="dO3F9exemRdHoXxGHr"/>
但在 C# 中我可以创建 View 状态,例如:
viewstate["x"]="Hi";
那么有什么区别???
以及字符串“Hi”保存在哪里?在这隐藏的地方还是哪里?
最佳答案
When a page is rendered, it serializes its view state into a base-64 encoded string using the LosFormatter class and (by default) stores it in a hidden form field. On postback, the hidden form field is retrieved and deserialized back into the view state's object representation, which is then used to restore the state of the controls in the control hierarchy.
这意味着它保存在这个隐藏字段
中,但它是编码的
。阅读 MSDN article了解更多信息。这句话来自6.解析 View 状态。
如果您有兴趣,可以解析 ViewState 并查看他的“真实值”。你可以搜索 View 状态解析器,经过研究我发现了这个Website
关于c# - 查看源代码中的viewsate ["x"]和__viewstate有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27871585/