Brian Webster
Brian Webster

Reputation: 30855

ASP.NET - Viewstate Size

Is there a reliable method for viewing the size of the viewstate on any given postback?

Upvotes: 7

Views: 6918

Answers (6)

Vasyl Senko
Vasyl Senko

Reputation: 1829

In Google Chrome you can use Chrome Viewstate or Viewstate indicator modules

Upvotes: 4

Matt J.
Matt J.

Reputation: 1830

Trace could be overkill sometimes. You can add this javascript to the page see quickly see how the ViewState grows as you click around.

<script type="text/javascript">
    alert('Viewstate is now ' + $('#__VIEWSTATE').val().length + ' bytes.');
</script>

Upvotes: 6

Ola Karlsson
Ola Karlsson

Reputation: 9193

You have a few options:

  • Using Trace
  • Using a browser plugin
  • Adding code to your project for extracting the viewstate size

I found this article quite useful "Determining an ASP.NET Page's View State Footprint" and it covers the options mentioned above.

However what I ended up doing when I needed to look at the viewstate size etc. of a application I was brought in to work on, was to use a tool called "ASP.NET ViewState Helper". What I liked about that tool was that I could run it as a standalone executable, no installation of plugins required and no changing of the code required.

The drawback is that it only works for IE but in my case that was fine.

Upvotes: 1

Martin Vobr
Martin Vobr

Reputation: 5823

I would recommend using FireFox addon called "Viewstate Size". Quick, simple and convenient.

alt text

https://addons.mozilla.org/en-US/firefox/addon/5956/

Upvotes: 11

rtpHarry
rtpHarry

Reputation: 13125

To view it in the page at the bottom of each request you can enable page level tracing like:

<%@ Page Trace="true" %>

You can read more about this technique here:

Upvotes: 6

Sundararajan S
Sundararajan S

Reputation: 1378

  1. Enable Trace in the web.config.
  2. Browse the application http:////Trace.axd
  3. In the "Control Tree" Section , sum up the ViewState Size and Control state Size of the controls.

Upvotes: 7

Related Questions