RadCompression giving SessionPageStatePersister error

9 posts, 1 answers
  1. Damodar
    Damodar avatar
    55 posts
    Member since:
    Jan 2011

    Posted 18 Oct 2012 Link to this post

    Hi,

    I am using "RadCompression" to reduce size viewstate and session.
    In test and dev machine the article work fine. 

    But I am getting following error in our live server we are not using any web farm.
    "System.ArgumentException: SessionPageStatePersister can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive."

    When I use HiddenFieldPageStateCompression it doesn't compress much.

    Any solutions?



    Best Regards,
    Damodar
  2. Martin
    Admin
    Martin avatar
    811 posts

    Posted 22 Oct 2012 Link to this post

    Hello Damodar,

    We have not received any reports about RadCompression causing similar issues. Could you please provide more details about how to reproduce the problem on our side?

    All the best,
    Martin
    the Telerik team
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Damodar
    Damodar avatar
    55 posts
    Member since:
    Jan 2011

    Posted 22 Oct 2012 Link to this post

    Hi Martin,

    I have successfully implement RadCompression to Test Server.
    I'll jot down computer structure if you can pin point any difference!

    Our Production server is Windows Server 2008 64 bit with SP 2.
    We have .net framework 2.0 3.5 sp1 and 4.5 installed and IIS 7.0
    We don't have dynamic content compression in IIS 7.0 (does it make any difference?)
    Telerik.Web.UI.dll File and Production version 2012.2.912.40
    Telerik.Web.UI.xml Created 2/8/2011 modified 9/26/2012.

    Test Server is Windows Server 2008 R2 Standard
    Telerik.Web.UI.dll File and Production version 2012.2.912.40
    and Telerik.Web.UI.Skins.dll same version as UI.dll.
    Doesn't have Telerik.Web.UI.xml file.
    We have dynamic content compression in IIS 7.0

    I have browser.browser file in Test Server as
    <adapter controlType="System.Web.UI.Page" adapterType="Telerik.Web.UI.RadSessionPageStateCompression" />
    Which is working as it should be and reducing page size(viewstate and session) significantly.
     
    But when I use same adapterType in Production server's browser.browser file. It is giving following error

    Type : System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : System.Web.HttpException (0x80004005): Error executing child request for /UnhandledError.aspx. ---> System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: SessionPageStatePersister can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive.

       at System.Web.UI.SessionPageStatePersister..ctor(Page page)

       at Telerik.Web.UI.RadSessionPageStateCompression.GetStatePersister()

       at System.Web.UI.Page.get_PageStatePersister()

       at System.Web.UI.Page.SavePageStateToPersistenceMedium(Object state)

       at System.Web.UI.Page.SaveAllState()

       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

       at System.Web.UI.Page.HandleError(Exception e)

       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

       at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

       at System.Web.UI.Page.ProcessRequest()

    Best Regards,
    Damodar


  5. Martin
    Admin
    Martin avatar
    811 posts

    Posted 25 Oct 2012 Link to this post

    Hello Damodar,

    As far as I see the exception is thrown in the SessionPageStatePersister constructor. Could you please confirm that SessionState / ViewState is enabled (actually NOT disabled) in the page you request?

    To verify that the problem is not caused by RadCompression you can use your own Page adapter that overrides the default SessionPageStatePersister. Instead of using RadSessionPageStateCompression you can add the code bellow the App_Code directory on your production server:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI.Adapters;
    using System.Web.UI;
     
    public class MyCustomPersiter : PageAdapter
    {
        public override System.Web.UI.PageStatePersister GetStatePersister()
        {
            return new MyCustomSessionStatePersister(base.Page);
        }
    }
    public class MyCustomSessionStatePersister : SessionPageStatePersister
    {
        public MyCustomSessionStatePersister(Page page)
            : base(page)
        {
     
        }
    }

    And here is how the .browser file should be modified in the App_Browsers folder:

    <browsers>
      <!--<browser refID="Default">
        <controlAdapters>
          <adapter controlType="System.Web.UI.Page" adapterType="Telerik.Web.UI.RadHiddenFieldPageStateCompression" />
        </controlAdapters>
      </browser>-->
      <browser refID="Default">
        <controlAdapters>
          <adapter controlType="System.Web.UI.Page" adapterType="MyCustomPersiter"></adapter>
        </controlAdapters>
      </browser>
    </browsers>

    If the problem exists even after RadSessionPageStateCompression is replaced with the code above, then it would be clear that RadCompression is not involved.

    I hope this helps.

    Greetings,
    Martin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Damodar
    Damodar avatar
    55 posts
    Member since:
    Jan 2011

    Posted 29 Oct 2012 Link to this post

    Hi Martin,

    ViewState is disabled on some of the pages.
    Can RadCompression ("RadSessionPageStateCompression") work for pages which has viewstate enabled?
    And ignore page where viewstate is disabled! 
    If yes how to do that?
    Why error is not happening in Test/dev environment?

    Best Regards,
    Damodar
  7. Answer
    Martin
    Admin
    Martin avatar
    811 posts

    Posted 01 Nov 2012 Link to this post

    Hello Damodar,

    Please find the answers to your questions bellow:

    "ViewState is disabled on some of the pages." - You should exclude those pages from viewstate compression:

    [RadCompressionSettings(StateCompression=CompressionType.None)]
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
     
        }
    }


    "Can RadCompression ("RadSessionPageStateCompression") work for pages which has viewstate enabled? And ignore page where viewstate is disabled!" -> Yes - just enable the RadSessionPageStateCompression for the application (in the browser file) and disable it only for pages where it is not needed.
    "If yes how to do that?" -> use the RadCompressionSettings attribute demonstrated in the code above.
    "Why error is not happening in Test/dev environment?" -> I suspect that this is due to different configuration settings.

    I hope this helps.

    All the best,
    Martin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  8. Damodar
    Damodar avatar
    55 posts
    Member since:
    Jan 2011

    Posted 07 Nov 2012 Link to this post

    Hi Martin,

    If the session is expired and user click any link in the page following error is caught in application level

    Error Message:Specified cast is not valid.

     Trace   at System.Web.UI.SessionPageStatePersister.Load()


    What do you suggest, OR How to handle this scenario?

    Best Regards,
    Damodar
  9. O'Man
    O'Man avatar
    34 posts
    Member since:
    Oct 2009

    Posted 08 Nov 2012 Link to this post

    hi

    why not increse your sesion timeouts

    http://msdn.microsoft.com/en-us/library/h6bb9cz9%28v=vs.71%29.aspx

    chairs
  10. Damodar
    Damodar avatar
    55 posts
    Member since:
    Jan 2011

    Posted 08 Nov 2012 Link to this post

    Hi O'Man,

    We have session timeout set to 120 that is 2 hours.

    It is not a major issue.
    But after deployment, 
    Or if someone left their page open for longer than timeout, it will happen.

    I am asking for that scenario.

    Best Regards,
    Damodar
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017