在.NET中如何摆脱视图状态的完全 [英] How to get rid of View State completely in .NET
本文介绍了在.NET中如何摆脱视图状态的完全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能摆脱:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="..."/>
彻底!
推荐答案
您需要添加的EnableViewState =假的@Page指令中的Default.aspx文件。
You need to add the EnableViewState="false" to the @Page directive in the Default.aspx file.
<%@ Page Language="C#" AutoEventWireup="true"
Codebehind="Default.aspx.cs" Inherits="Sample._Default"
EnableViewState="false" %>
然后,添加以下code到Default.aspx.cs文件。这从生成的HTML删除隐藏字段。
Then, add the following code to the Default.aspx.cs file. This removes the hidden field from the generated HTML.
#region Disable ViewState
protected override void SavePageStateToPersistenceMedium(object state)
{
}
protected override object LoadPageStateFromPersistenceMedium()
{
return null;
}
#endregion
这篇关于在.NET中如何摆脱视图状态的完全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文