HOWTO: Limit Viewstate length

In some occa­sions browsers may block or trun­cate  gen­er­ated view­state due to it’s length. This short tweak may solve the issue  by divid­ing the view­state to inde­pen­dent hid­den fields based on the num­ber you pro­vide as value. In this exam­ple max­PageS­tate­Field­Length set to 50 this means when view­state get beyond 50 char­ac­ters it will be bro­ken to dif­fer­ent hid­den fields hold­ing viewstate’s value

code :


<system.web>
<pages maxPageStateFieldLength="50">
<controls />
</pages>
</system.web>

* put this code as <pages> attribute inside of <web.section> sec­tion in web.config

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • LinkedIn
  • StumbleUpon
  • Technorati
  • Live
  • PDF

Tags: ASP.NET, viewstate, web.config

One comment

  1. I never knew this was even pos­si­ble :)

Leave a comment