Disable ViewState

M

MCM

I am trying to disable ViewState at the application level. I have the
following line in my web.config:

<pages enableViewState="false"></pages>

But it is not working. What can I do?
 
S

Steven Cheng [MSFT]

Hi MCM,

As for "disabling" ViewState, you can set "ViewState" at several different
levels:

* at web.config <pages> level
* at @page directive level, this can override the web.config level
* at control's level, this rely on whether the page's viewstate is enabled.

As for the problem behavior you encountered, how did you get that the
ViewState is not disabled? I've performed a simple test as below

*disable viewstate at web.config <pages> level

* create a new page and put a Label on the page

I can find that the Label's ViewState is not available.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.





--------------------
 
M

MCM

When I view the source of the page output, there is still a hidden field
being generated for ViewState and it does not have an empty value.
 
S

Steven Cheng [MSFT]

Thanks for your reply MCM,

As for the hidden "__VIEWSTATE" html hidden field, it is the expected
behavior that ASP.NET page still output it even if you disable viewstate.
This is because this hidden field is not only used for storing page or
control's ViewState data. It also contains some data for identifying the
current status(such as status between multiple postback) so that the
server-side can differenitate each request from the client-side for the
same page.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: =?Utf-8?B?TUNN?= <[email protected]>
Subject: RE: Disable ViewState
Date: Mon, 15 Sep 2008 14:59:01 -0700
 
M

MCM

Ok. Thanks.

Steven Cheng said:
Thanks for your reply MCM,

As for the hidden "__VIEWSTATE" html hidden field, it is the expected
behavior that ASP.NET page still output it even if you disable viewstate.
This is because this hidden field is not only used for storing page or
control's ViewState data. It also contains some data for identifying the
current status(such as status between multiple postback) so that the
server-side can differenitate each request from the client-side for the
same page.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top