locked
SessionPageStatePersister does very little to reduce viewstate size RRS feed

  • Question

  • User1364489113 posted

    Hi, I'm trying to use SessionPageStatePersister to help reduce the size of my viewstate, but it seems to do next to nothing.

    On a very large page with a viewstate hidden field of 185k it reduces it to only 171k.

    I have been using the control adapter method from msdn, but also tried overriding the page property. 

    Has anyone seen this before?

    BTW. I am using Telerik Ajax and Peter Blum validation controls. 

    Tuesday, March 20, 2007 10:16 PM

Answers

  • User-877203302 posted

    I think this is the ControlState information that remains in your page.

    The ControlState is used by the GridView control to work correctly even if the ViewState is disabled on the page or the control.

    ControlState persistence is not handled the same way as the ViewState, that's why you cannot store a ControlSession in session the same way as you do with SessionPagePersister.
    To do it, you should try to insert the following in your Web.Config file :

    <configuration>
        <system.web>
            <browserCaps>
                <case>RequiresControlStateInSession=true</case>
            </browserCaps>
        </system.web>
    </configuration>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 21, 2007 11:09 AM

All replies

  • User-877203302 posted

    I think this is the ControlState information that remains in your page.

    The ControlState is used by the GridView control to work correctly even if the ViewState is disabled on the page or the control.

    ControlState persistence is not handled the same way as the ViewState, that's why you cannot store a ControlSession in session the same way as you do with SessionPagePersister.
    To do it, you should try to insert the following in your Web.Config file :

    <configuration>
        <system.web>
            <browserCaps>
                <case>RequiresControlStateInSession=true</case>
            </browserCaps>
        </system.web>
    </configuration>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 21, 2007 11:09 AM
  • User1364489113 posted

    Thanks, that seems to work.

    I thought that browsercaps was deprecated in .net 2.0??
     

    Wednesday, March 21, 2007 6:47 PM
  • User-877203302 posted

    I thought that browsercaps was deprecated in .net 2.0??

    I dont know... As I learnt from Szökelizer and Reflector, it seems to be the only way to store the ControlState in Session.

    Thursday, March 22, 2007 6:25 AM
  • User669157455 posted

    Here is how you can completely eliminate the ViewState Hidden Field.. I reduced it from 200k to 62 bytes,

     

    http://ashishnangla.com/2011/07/21/reducing-size-of-viewstate-in-asp-net-webforms-by-writing-a-custom-viewstate-provider-pagestatepersister-part-12/

    Tuesday, November 22, 2011 1:25 AM