Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Minimizing viewstate on pages

Posted on 2004-10-20
7
325 Views
Last Modified: 2012-08-13
Hi experts,

I'd like to optimize my aspx pages for Search Engines like google. One thing I have to do is to minimize or delete the viewstate hidden input field. I'm using user controls, so in both pages and user controls I considered the tag: EnableViewState="False". The problem is that viewstate is still in the result pages.

How can I delete viewstate from my aspx result pages?

Carlos V.
0
Comment
Question by:CARLOSVILLACRIZ
7 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 12366715
Hi CARLOSVILLACRIZ,

see here : http://www.dotnetjohn.com/articles/articleid71.aspx
ViewState and Performance
By default ViewState is enabled in an ASP.NET application. Developers should be aware that any data in ViewState automatically makes a round trip to the client. Because the round trips contribute to a performance overhead, it is important to make judicious use of ViewState.

This is especially important when your application contains complex controls such as a DataList or DataGrid but is generally true when you are presenting considerable information via a server control. An example might be presented a list of countries for selection ... you don't want to impose the overhead of transferring all the country text back and forth from server to client and vice versa more than is strictly necessary. It will significantly impact on response times if you don't disable the ViewState either for the page as a whole or for the specific controls causing the unnecessary overhead.

Whenever you complete a web forms page you should review the controls in the page and consider what is being passed in the ViewState and whether you really need all that information to be passed. To optimise Web page size you may want to disable ViewState in the following cases, amongst others:

when a page does not postback to itself
when there are no dynamically set control properties
when the dynamic properties are set with each request of the page
ASP.NET provides you with complete flexibility to disable ViewState. As already discussed you are able to disable ViewState at the control and page level. Additionally you may disable ViewState at the application and machine level via the web.config and machine.config files via the following directive:

<Pages enableViewState="false"/>  


Regards!
B..M
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 12367235
just check by adding the attribute enableciewstate =false within the "<%@ Page"  tag .. But I have noticed that even after doing all this the "__VIEWSTATE" hidden input view is till present in the HTML page.... I am not very sure about this, but probably the session state is also maintained using the viewstate .. so even u disable it .. some information is passed in the viewstate .. this will not contain information about the values of the control but other things that the aspx page need for its processing later and the size will not change drastically on multiple submits as it would have in the case the viewstate was enabled and u have many controls in the page ...
0
 
LVL 26

Accepted Solution

by:
Rejojohny earned 500 total points
ID: 12367295
i noticed that viewstate is still shown in the HTML page when we disable sesssionstate too .. also if i had no controls within my page and just my <form> tag, it still has some viewstate .. but by removing the runat=server property for the form tag .. the viewstate is removed .. so what i could conclude is that it is toring some information about the form in the viewstate even when u disable viewstate for the page ...
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 26

Expert Comment

by:Rejojohny
ID: 12367403
0
 
LVL 7

Expert Comment

by:smolam
ID: 12367827
You could also use a provider, very powerful and very flexible:  here is an article which has source code and examples, it shows you how to put the Viewstate into a SQL database or a file or anything else you want.

http://www.thecodeproject.com/aspnet/ViewStateProvider.asp
0
 
LVL 33

Expert Comment

by:raterus
ID: 12370011
You can never completely rid yourself of the hidden viewstate form field, it's used by some system level controls.  I have read this officially, but can't seem to find it now.
0
 

Author Comment

by:CARLOSVILLACRIZ
ID: 12390127
Hi experts,

I solved this thing about the viewstate deleting all the controls and generating them using response.write... doing this any viewstate is written.. we had to do this with 2 or 3 user controls that will be in a lot of pages that must be scanned with Search Engines.. so we got the requirement to delete any dynamic or strange generated code (viewstate included)...

Thanks by your suggestions.. I'll give points to Rejojohny because he tested pages and know that disable viewstate is not possible if you have any control in your page.. is not only necessary to write: enableViewState="false"

Carlos V
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
designing in object programming 12 94
asp day pilot 3 23
how to change the view engine in visual studio 2015 enterprises edition 7 94
FInd Image Control Gridview 3 19
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question