<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>UC&#039;s Corner &#187; viewstate</title>
	<atom:link href="http://yussi.nl/index.php/tag/viewstate/feed" rel="self" type="application/rss+xml" />
	<link>http://yussi.nl</link>
	<description>Yussi Ariefiyono</description>
	<lastBuildDate>Fri, 25 Jun 2010 12:57:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>disable remove viewstate aspx</title>
		<link>http://yussi.nl/index.php/disable-remove-viewstate-aspx.html</link>
		<comments>http://yussi.nl/index.php/disable-remove-viewstate-aspx.html#comments</comments>
		<pubDate>Mon, 11 May 2009 14:39:00 +0000</pubDate>
		<dc:creator>yussi ariefiyono</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[viewstate]]></category>

		<guid isPermaLink="false">/post/disable-remove-viewstate-aspx.aspx</guid>
		<description><![CDATA[
Problem:
Annoying LONG viewstate


&#60;input type=&#34;hidden&#34; name=&#34;__VIEWSTATE&#34; id=&#34;__VIEWSTATE&#34; value=&#34;/wEPDwULLTEyMjcx
NDEzNzQPZBYCZg9kFgQCAQ9kFgICAg8VAh4vV29ybGRHcmFubnkvanMvZGRhY2NvcmRpb24u
anMkL1dvcmxkR3Jhbm55L2pzL2pxdWVyeS0xLjIuMi5wYWNrLmpzZAIDD2QWBAIDDxYCHgtfIUl0
ZW1Db3VudAIKFhRmD2QWBAIBDw8WAh4LTmF2aWdhdGVVcmwFFH4vUGFnaW5hLzIvaG9tZS5h
c3B4ZBYCZg8VAQRIb21lZAIDDxYCHwACARYCAgEPZBYCAgEPDxYCHwEFFX4vUGFnaW5hLzQvc3V
iLTEuYXNweGQWAmYPFQEFc3ViIDFkAgEPZBYEAgEPDxYCHwEFG34vUGFnaW5hLzMvb3JnYW5pc2F0a
WUuYXNweGQWAmYPFQELT3JnYW5pc2F0aWVkAgMPFgIfAAICFgQCAQ9kFgICAQ8PFgIfAQUUfi9QYWdpb
mEvNS9zdWIyLmFzcHhkFgJmDxUBBHN1YjJkAgIPZBYCAgEPDxYCHwEFGH4vUGFnaW5hLzgvbmV3LXBhZ2&#34; /&#62;


LOL.. long huh 


Solution:
put this code in your .cs page



//overwrite the&#160; SavePageStateToPersistenceMedium and LoadPageStateFromPersistenceMedium
protected override void SavePageStateToPersistenceMedium(object viewState)
&#160;&#160;&#160; {
&#160;&#160;&#160; }
&#160;&#160;&#160; protected override object LoadPageStateFromPersistenceMedium()
&#160;&#160;&#160; {
&#160;&#160;&#160;&#160;&#160;&#160;&#160; return null;
&#160;&#160;&#160; }



// Remove completely after rendering html code 
&#160;protected override void Render(HtmlTextWriter output)
&#160;&#160;&#160; {
&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.IO.StringWriter stringWriter = <a href="http://yussi.nl/index.php/disable-remove-viewstate-aspx.html" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>
<strong>Problem:</strong><br />
Annoying LONG viewstate
</p>
<pre>
<em>&lt;<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">&quot;hidden&quot; </span><span class="attribute-name">name</span>=<span class="attribute-value">&quot;__VIEWSTATE&quot; </span><span class="attribute-name">id</span>=<span class="attribute-value">&quot;__VIEWSTATE&quot; </span><span class="attribute-name">value</span>=<span class="attribute-value">&quot;/wEPDwULLTEyMjcx
NDEzNzQPZBYCZg9kFgQCAQ9kFgICAg8VAh4vV29ybGRHcmFubnkvanMvZGRhY2NvcmRpb24u
anMkL1dvcmxkR3Jhbm55L2pzL2pxdWVyeS0xLjIuMi5wYWNrLmpzZAIDD2QWBAIDDxYCHgtfIUl0
ZW1Db3VudAIKFhRmD2QWBAIBDw8WAh4LTmF2aWdhdGVVcmwFFH4vUGFnaW5hLzIvaG9tZS5h
c3B4ZBYCZg8VAQRIb21lZAIDDxYCHwACARYCAgEPZBYCAgEPDxYCHwEFFX4vUGFnaW5hLzQvc3V
iLTEuYXNweGQWAmYPFQEFc3ViIDFkAgEPZBYEAgEPDxYCHwEFG34vUGFnaW5hLzMvb3JnYW5pc2F0a
WUuYXNweGQWAmYPFQELT3JnYW5pc2F0aWVkAgMPFgIfAAICFgQCAQ9kFgICAQ8PFgIfAQUUfi9QYWdpb
mEvNS9zdWIyLmFzcHhkFgJmDxUBBHN1YjJkAgIPZBYCAgEPDxYCHwEFGH4vUGFnaW5hLzgvbmV3LXBhZ2&quot; </span><span class="error"><span class="attribute-name">/</span></span>&gt;</em>
</pre>
<p>
LOL.. long huh <img src='http://yussi.nl/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />
</p>
<p>
<strong>Solution:</strong><br />
put this code in your .cs page<br />

</p>
<p>
<em>//overwrite the&nbsp; </em><em>SavePageStateToPersistenceMedium</em> and <em>LoadPageStateFromPersistenceMedium</em><br />
<em>protected override void SavePageStateToPersistenceMedium(object viewState)<br />
&nbsp;&nbsp;&nbsp; {</p>
<p>&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; protected override object LoadPageStateFromPersistenceMedium()<br />
&nbsp;&nbsp;&nbsp; {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;</p>
<p>&nbsp;&nbsp;&nbsp; }</em>
</p>
<p>
<em><br />
// Remove completely after rendering html code <br />
&nbsp;protected override void Render(HtmlTextWriter output)<br />
&nbsp;&nbsp;&nbsp; {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.IO.StringWriter stringWriter = new System.IO.StringWriter(stringBuilder);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (Control ctrl in this.Controls)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ctrl.RenderControl(htmlWriter);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String html = stringBuilder.Replace(&quot;/&gt;&quot;, &quot;&gt;&quot;).ToString();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int intViewStart = html.IndexOf(&quot;&lt;input type=\&quot;hidden\&quot; name=\&quot;__VIEWSTATE\&quot;&quot;);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int intViewFinish = html.IndexOf(&quot;&gt;&quot;, intViewStart) + 1;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strViewTag = html.Substring(intViewStart, intViewFinish &#8211; intViewStart);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Diagnostics.Debug.WriteLine(strViewTag);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; html = html.Replace(strViewTag, &quot;&quot;);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; output.Write(html);</p>
<p>&nbsp;&nbsp;&nbsp; }</em>
</p>
<p>
and WALA! its gone!!</p>
]]></content:encoded>
			<wfw:commentRss>http://yussi.nl/index.php/disable-remove-viewstate-aspx.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
