ViewStateMode Disabled but still getting ViewState element(ViewStateMode 已禁用但仍获取 ViewState 元素)
问题描述
我有一个 ASP.NET 4.0 webforms 站点,我有 MasterPage,所以它被设置为 ViewStateMode="Disabled" 以及类似设置的内容占位符.
I have a ASP.NET 4.0 webforms site where I have the MasterPage so it is set to ViewStateMode="Disabled" along with the content placeholders being set similarly.
当我查看我的页面时,我仍然会看到呈现的 ViewState 字段,然后我尝试将 ViewStateMode="Disabled" 添加到页面级别,但没有任何改变.
When I'd view my page I'd still see a ViewState field rendered, I then tried adding the ViewStateMode="Disabled" to the page level also but that didn't change anything.
推荐答案
我不知道框架 4 对 ViewState 的最新更改,但您必须考虑到呈现给客户端的 ViewState 字段有 2 个组件:ViewState 本身和 ControlState.
I'm not aware of latest changes on ViewState for the framework 4 but you have to take into account that the ViewState field rendered to the client has 2 components: ViewState itself and ControlState.
无论您是否启用了 ViewState,ControlState 总是在 viewstate 字段上发送给客户端.
The ControlState is ALWAYS sent to the client on the viewstate field no matter if you have enabled ViewState or not.
因此,您可以期望大幅减少发送到客户端的视图状态字段的大小,但不会完全删除它.
So you can expect to drastically reduce the size of the viewstate field sent to the client but not completely remove it.
控件状态包含控件需要在回发中保持以按预期工作的最少内容.
Control state contains the minimal things that a control needs to persist across postbacks in order to work as expected.
控制状态
除了视图状态,ASP.NET 还支持控件状态.页面使用控件状态来保存必须在回发之间保留的控件信息,即使页面或控件的视图状态被禁用.与视图状态一样,控件状态存储在一个或多个隐藏字段中.
In addition to view state, ASP.NET supports control state. The page uses control state to persist control information that must be retained between postbacks, even if view state is disabled for the page or for a control. Like view state, control state is stored in one or more hidden fields.
http://msdn.microsoft.com/en-us/library/bb386448.aspx
这篇关于ViewStateMode 已禁用但仍获取 ViewState 元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ViewStateMode 已禁用但仍获取 ViewState 元素
基础教程推荐
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
