title: Access __VIEWSTATE & __EVENTVALIDATION in C#
body: <p>In <a href="http://en.wikipedia.org/wiki/ASP.NET" rel="nofollow">ASP.NET</a>, is it possible to get the values of __VIEWSTATE and __EVENTVALIDATION hidden fields into a variable in C# (server side) in, let's say, overriding the <code>Render</code> method?</p>
  
  <p>I have tried:</p>
  
  <pre><code>protected override void Render(HtmlTextWriter writer)
  {
      StringBuilder stringBuilder = new StringBuilder();
      StringWriter stringWriter = new StringWriter(stringBuilder);
      HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
  
      base.Render(htmlWriter);
      string temp = stringBuilder.ToString();
  }
  </code></pre>
  
  <p>This gives me the entire ASP.NET output. We can get the values by using a string function, but I did not find it a very clean solution. Is there a better way to do this?</p>
  
  <p>What I actually want is the values of __VIEWSTATE &amp; __EVENTVALIDATION when the first request is made and not after the postback is done. That is when the output stream if formed when the first request is made.</p>