{"id":62796,"date":"2019-03-12T20:49:47","date_gmt":"2019-03-13T03:49:47","guid":{"rendered":"https:\/\/www.bruceclay.com\/eu\/?page_id=62796"},"modified":"2019-04-01T11:13:08","modified_gmt":"2019-04-01T18:13:08","slug":"viewstate","status":"publish","type":"page","link":"https:\/\/www.bruceclay.com\/eu\/viewstate\/","title":{"rendered":"View State"},"content":{"rendered":"<hr \/>\n<p>View State is an ASP.NET technology that allows for different states of information to be stored. It is generally used in Web form pages that cause a subsequent server request for the same page, called a postback. This allows users to save previous searches on return visits. The downside is this:<\/p>\n<pre>&lt;input type=\"hidden\" name=\"__VIEWSTATE\" value=\"dDwtMTU3ODMxMzE0NTt0PDtsPGk8MD47aTwx\nPjtpPDI+O2k8ND47PjtsPHQ8cDxsPFRleHQ7PjtsPENhcGl0YWwgRGVzaWduIC0gSG9tZTs+Pjs7Pjt0PHA8\nbDxUZXh0Oz47bDxcPE1FVEEgTkFNRT0iZGVzY3JpcHRpb24iIENPTlRFTlQ9IiJcPjs+...\" \/&gt;&gt;<\/pre>\n<p>Had the entire View State tag been included, this article would have been over three pages long. This is obviously a problem for SEO purposes because as this tag gets longer, the content of your site is encountered by spiders later and later in the code. There are a couple of methods that can be used to either move the View State to the end of the page, or to completely disable it, depending on how your server and your site are set up.<\/p>\n<p>The first implementation &mdash; moving it to the bottom of your pages &mdash; is the least server-intensive method. A few lines of code are added to the server:<\/p>\n<pre>Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter) \nDim stringWriter As System.IO.StringWriter = New System.IO.StringWriter \nDim htmlWriter As HtmlTextWriter = New HtmlTextWriter(stringWriter) \nMyBase.Render(htmlWriter) \nDim html As String = stringWriter.ToString() \nDim StartPoint As Integer = \n  html.IndexOf(\"&lt;input type=\"\"hidden\"\" name=\"\"__viewstate\"\"\") \nIf StartPoint &gt;= 0 Then 'does __viewstate exist? \nDim EndPoint As Integer = html.IndexOf(\"\/&gt;\", StartPoint) + 2 \nDim viewstateInput As String = html.Substring(StartPoint, EndPoint - StartPoint) \nhtml = html.remove(StartPoint, EndPoint - StartPoint) \nDim FormEndStart As Integer = html.IndexOf(\"&lt;\/form&gt;\") - 1 \nIf FormEndStart &gt;= 0 Then \nhtml = html.Insert(FormEndStart, viewstateInput) \nEnd If \nEnd If \nwriter.Write(html) \nEnd Sub<\/pre>\n<p>What this does is override the Render() method for the page and move the View State from the default location at the top of the page to the bottom of the page, resulting in better spidering.<\/p>\n<p>Alternatively, you can implement the use of sessions instead of the View State. This is a little more server-intensive, but it may be worth considering if you have multiple controllers on one page that use the View State, and it could even result in faster performance in the long run. Basically what this does is &#8220;force&#8221; the View State off the page and places it on the server, thus overriding the <strong>SavePageStateToPersistenceMedium<\/strong> and <strong>LoadPageStateFromPersistenceMedium<\/strong> mechanisms that store and retrieve View State data. By doing this, the View State process is intercepted. In other words, you are taking the information stored in the View State and inserting it somewhere else, like a SessionID. The benefit of this is that your pages will be much lighter without the View State, and form data is still able to be saved and retrieved upon subsequent visits to a site. Also, spiderability of a Web page or site is increased since HTML coded pages don&#8217;t have to carry around the View State baggage, resulting in reduced page sizes and rendering times. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>View State is an ASP.NET technology that allows for different states of information to be stored. It is generally used in Web form pages that cause a subsequent server request for the same page, called a postback. This allows users to save previous searches on return visits. The downside is this: &lt;input type=&#8221;hidden&#8221; name=&#8221;__VIEWSTATE&#8221; value=&#8221;dDwtMTU3ODMxMzE0NTt0PDtsPGk8MD47aTwx [&hellip;]<\/p>\n","protected":false},"author":101022,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"tags":[],"class_list":["post-62796","page","type-page","status-publish","hentry"],"acf":[],"yoast_head":"<title>View State - Bruce Clay Europe<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.bruceclay.com\/eu\/viewstate\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"View State - Bruce Clay Europe\" \/>\n<meta property=\"og:description\" content=\"View State is an ASP.NET technology that allows for different states of information to be stored. It is generally used in Web form pages that cause a subsequent server request for the same page, called a postback. This allows users to save previous searches on return visits. The downside is this: &lt;input type=&quot;hidden&quot; name=&quot;__VIEWSTATE&quot; value=&quot;dDwtMTU3ODMxMzE0NTt0PDtsPGk8MD47aTwx [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.bruceclay.com\/eu\/viewstate\/\" \/>\n<meta property=\"og:site_name\" content=\"Bruce Clay Europe\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-01T18:13:08+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.bruceclay.com\\\/eu\\\/viewstate\\\/\",\"url\":\"https:\\\/\\\/www.bruceclay.com\\\/eu\\\/viewstate\\\/\",\"name\":\"View State - Bruce Clay Europe\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bruceclay.com\\\/eu\\\/#website\"},\"datePublished\":\"2019-03-13T03:49:47+00:00\",\"dateModified\":\"2019-04-01T18:13:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.bruceclay.com\\\/eu\\\/viewstate\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.bruceclay.com\\\/eu\\\/viewstate\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.bruceclay.com\\\/eu\\\/viewstate\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.bruceclay.com\\\/eu\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"View State\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.bruceclay.com\\\/eu\\\/#website\",\"url\":\"https:\\\/\\\/www.bruceclay.com\\\/eu\\\/\",\"name\":\"Bruce Clay Europe\",\"description\":\"SEO and Internet Marketing Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.bruceclay.com\\\/eu\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>","yoast_head_json":{"title":"View State - Bruce Clay Europe","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.bruceclay.com\/eu\/viewstate\/","og_locale":"en_US","og_type":"article","og_title":"View State - Bruce Clay Europe","og_description":"View State is an ASP.NET technology that allows for different states of information to be stored. It is generally used in Web form pages that cause a subsequent server request for the same page, called a postback. This allows users to save previous searches on return visits. The downside is this: &lt;input type=\"hidden\" name=\"__VIEWSTATE\" value=\"dDwtMTU3ODMxMzE0NTt0PDtsPGk8MD47aTwx [&hellip;]","og_url":"https:\/\/www.bruceclay.com\/eu\/viewstate\/","og_site_name":"Bruce Clay Europe","article_modified_time":"2019-04-01T18:13:08+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.bruceclay.com\/eu\/viewstate\/","url":"https:\/\/www.bruceclay.com\/eu\/viewstate\/","name":"View State - Bruce Clay Europe","isPartOf":{"@id":"https:\/\/www.bruceclay.com\/eu\/#website"},"datePublished":"2019-03-13T03:49:47+00:00","dateModified":"2019-04-01T18:13:08+00:00","breadcrumb":{"@id":"https:\/\/www.bruceclay.com\/eu\/viewstate\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.bruceclay.com\/eu\/viewstate\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.bruceclay.com\/eu\/viewstate\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.bruceclay.com\/eu\/"},{"@type":"ListItem","position":2,"name":"View State"}]},{"@type":"WebSite","@id":"https:\/\/www.bruceclay.com\/eu\/#website","url":"https:\/\/www.bruceclay.com\/eu\/","name":"Bruce Clay Europe","description":"SEO and Internet Marketing Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.bruceclay.com\/eu\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.bruceclay.com\/eu\/wp-json\/wp\/v2\/pages\/62796","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bruceclay.com\/eu\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bruceclay.com\/eu\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bruceclay.com\/eu\/wp-json\/wp\/v2\/users\/101022"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bruceclay.com\/eu\/wp-json\/wp\/v2\/comments?post=62796"}],"version-history":[{"count":0,"href":"https:\/\/www.bruceclay.com\/eu\/wp-json\/wp\/v2\/pages\/62796\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bruceclay.com\/eu\/wp-json\/wp\/v2\/media?parent=62796"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bruceclay.com\/eu\/wp-json\/wp\/v2\/tags?post=62796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}