我该如何关闭视图状态良好? [英] How do I turn off viewstate for good?

查看:198
本文介绍了我该如何关闭视图状态良好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从PHP背景我喜欢使用干净的网址,从一个服务数据抓取到另一个来了。

Coming from a PHP background I love using clean URLs to grab data from one service to another.

不过,我的一些ASP.NET项目中,我得到了可怕的ViewState的参数我的网址。

However, on some of my ASP.NET projects I get the horrible ViewState parameter in my URLs.

有没有办法在全球范围内关闭这个功能?

Is there a way to turn this off globally?

什么影响这将对我的ASP.NET应用程序?

What affect will this have on my ASP.NET app?

推荐答案

您可以关闭视图状态为整个网站是这样的:

You can turn off viewstate for the whole site like this:

    <system.web>
<pages enableViewState="false" />

这是说,你不应该得到它的URL。的ViewState是发送给服务器回发(通常使用后)的隐藏字段。它使控件的状态时,页面被呈现给客户,与每次回发发送。如果一切正常的应用程序,你可以切换到使用POST(问题的形式肯定使用GET),如果不看看乔恩的答案。

That said, you shouldn't be getting it on the url. ViewState is a hidden field that is sent to the server with a postback (which normally uses post). It keeps the state of the controls when the page was rendered to the client, sending it with each postback. If it works for the application you could switch to use post instead (the problem form is surely using get), if not take a look at Jon's answer.

检查此链接的视图状态如何融入asp.net生命周期的详细信息:<一href=\"http://msdn.microsoft.com/en-us/library/ms972976.aspx\">http://msdn.microsoft.com/en-us/library/ms972976.aspx.

Check this link for more information on how the viewstate fits into the asp.net life cycle: http://msdn.microsoft.com/en-us/library/ms972976.aspx.

这篇关于我该如何关闭视图状态良好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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