何时启用/禁用Viewstate [英] When to enable/disable Viewstate

查看:78
本文介绍了何时启用/禁用Viewstate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除非我明确知道我将需要它们的视图状态,否则我通常禁用ASP.net控件的视图状态.我发现这可以显着减小生成的HTML的页面大小.

I generaly disable viewstate for my ASP.net controls unless I explicitly know I am going to require view state for them. I have found that this can significantly reduce the page size of the HTML generated.

这是好习惯吗?什么时候应该启用或禁用?

Is this good practice? When should be enabled or disabled?

推荐答案

是的,这是一个非常好的主意.有人可能会说,它应该像缓存一样默认由Microsoft禁用.

Yes it is a very good idea. One could argue that it should have been disabled by default by Microsoft, just like caching.

要查看Viewstate在增加尺寸方面有多糟糕,可以使用名为 Viewstate的工具分析器.当您具有已启用Viewstate的现有应用程序开发时,此功能特别有用.

To see how bad Viewstate is in terms of size increased you can use a tool called Viewstate Analyzer. This is particularly useful when you have an existing application developed with Viewstate enabled.

禁用Viewstate的另一个很好的理由是,当您有大量依赖它的组件时,要在以后的阶段禁用它真的很困难.

Another good reason to disable Viewstate is that it is really hard to disable at a later stage, when you have loads of components depending on it.

这篇关于何时启用/禁用Viewstate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆