title: Asp.Net Viewstate exceeds max request length
body: <p>I'm stuck with a problem that causes my WebApplication to crash on a regular bases. A Client (Browser) get the HTTP status code 500 after making some (more than 1) requests to the server. I turned on the IIS Failed Request Tracing and discoverd, that the request exceeded the max request limit:</p>
  
  <pre><code>Maximum request length exceeded
  </code></pre>
  
  <p>I looked at the hidden <code>__VIEWSTATE</code> field and found, that it contains some information I expected and a cryptic (probably base64 encoded) serialized object with 49,500 characters. I didn't know, why this was so large and Checked my Session and ViewState objectes in my code behind. But nothing was suspicious.</p>
  
  <p>Since I'm displaying 2 ASP.NET Charts and a large data table (5k rows and aprox 20 cols) I went into my Web.Config file and increased my request limit to</p>
  
  <pre><code>&lt;/system.web&gt;
    &lt;httpRuntime maxRequestLength="4194304"/&gt;    
  &lt;/system.web&gt;
  </code></pre>
  
  <p>That was kinda successfull, meaning that the server survived one more request bevore then crashing with an <code>OutOfMemoryException</code>, claiming there is no more memory available. </p>
  
  <p>By now, I'm pretty sure that there are some (and with some I mean tons) unwanted, unneccesary, most likely unused objects stored. (nice way of describing a memory leak ;) ).</p>
  
  <p>But at this point, I am lost. Is there any way I can look into the ViewState before its being serialized and check, what kind of objects are referenced there? Can I clear/delete/flush the ViewState/Session/whatever is responsible for this in order to have a clean serialized ViewState that does not exceed the default limit?</p>