locked
Unable to turn off viewstate RRS feed

  • Question

  • User1734965626 posted

    Hello,

    I've converted an old ASP.NET 1.1 (VB) web form, which uses "method=get", to ASP.NET 4.5 but it won't run because the viewstate is now very large at 95K, and so it says the URL is too long. I need to turn viewstate off but nothing has worked so far, e.g. I have set  EnableViewState="False" and ViewStateMode="Disabled" on every control, and at page level in the "<%@ Page" tag. I also tried "<pages enableViewState="false">" in the Web.config but the large viewstate is still generated! 

    Please help as I'm pulling my hair out!

    Note that I'm using IIS Express in Visual Studio 2012. The form is rather complex and I don't want to try switching to "method=post".

    Thanks

    Tuesday, April 30, 2013 10:49 AM

All replies

  • User163270948 posted

    I belive the viewstate will always be rendered, but an option is to make it blank by overriding the various methods on the page in question which deal with managing the viewstate.

    See the final answer on this page:

    http://stackoverflow.com/questions/2432972/completely-remove-viewstate-for-specific-pages

    The example is in C# but I'm sure you can convert to VB.

    Obviously removing the viewstate will mean any controls which rely on it may not work as expected.

    Tuesday, April 30, 2013 10:58 AM
  • User1734965626 posted

    Thanks, to me it seems to be a bug in .NET if I'm telling it not to use viewstate and yet it carries on using it anyway. Also what changed from ASP.NET 1.1 to 4.5 that the viewstate for the same page has grown from 693 characters to 95000?!

    Tuesday, April 30, 2013 1:32 PM