More in this section

Forums / Developing with Sitefinity / Moveing viewstate

Moveing viewstate

7 posts, 1 answered
  1. Roberto
    Roberto avatar
    146 posts
    Registered:
    08 Feb 2008
    11 Mar 2010
    Link to this post
    Hi All,

    Are there any good techniques to move the viewstate of the page to the bottom in sitefinity?

    Thanks,

    Rob
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Mar 2010
    Link to this post
    Hi Roberto Modica,

    You can create a  custom class that inherits from InternalPage  and override PageStatePersister method and return your custom implementation


    public class InterlanPageCustom : InternalPage
    {
        public InterlanPageCustom()
        {
        }
     
        protected override PageStatePersister PageStatePersister
        {
            get
            {
                // HERE YOU HAVE TO RETURN YOUR CUSTOM IMPLEMENTATION
                return base.PageStatePersister;
            }
        }
    }

    Another way is shown in Scott Hanselman's blog . You can also use HttpModule - Moving VIEWSTATE to the bottom of the page redux


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Roberto
    Roberto avatar
    146 posts
    Registered:
    08 Feb 2008
    15 Mar 2010
    Link to this post
    Hi Ivan,

    Thanks for the response.  I implemented the HttpModule option but i am having some issues.  The issues are not with the third party code and i woudnt ask about that, its to do with the IIS Settings.  For some reason the HttpModule was not working, so i adjusted the Application Pool (for some reason it was set to the default App Pool) so i changed it to the Classic .Net AppPool, which then got the HttpModule to work, but now images are not appearing and none of my url rewrites in the web.config work when they were in default app pool.

    What have i dont wrong. attached are two images showing the image issue.

    Thanks,

    Rob
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    15 Mar 2010
    Link to this post
    Hi Roberto Modica,

    Thank you for getting back to us.

    Could you please try to add your HttpModule in the section for Default Application pool in your web.config:
    <system.webServer>
      ...
      <modules>
        <remove name="ScriptModule"/>
        <remove name="Cms"/>
        <!--<remove name="LibraryModule"/>-->
        <remove name="RadUploadModule"/>
        <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="Cms" type="Telerik.Cms.Web.CmsHttpModule, Telerik.Cms"/>
        <!-- Http Module for extension mappings in Library module.-->
        <!--<add name="LibraryModule" type="Telerik.Libraries.LibraryHttpModule, Telerik.Libraries"/>-->
        <add name="RadUploadModule" preCondition="managedHandler" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI"/>
      </modules>

    For IIS 7.0 HttModules are registered in system.webServer/modules node, where as in IIS 6.0 they are registered in system.web/httpModules node.

    Regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  5. Roberto
    Roberto avatar
    146 posts
    Registered:
    08 Feb 2008
    17 Mar 2010
    Link to this post
    Hi Ivan,

    That did the trick, i should have known that from the url rewrite module documentation that tells you the same thing.

    Thanks,

    Rob
  6. Roberto
    Roberto avatar
    146 posts
    Registered:
    08 Feb 2008
    17 Mar 2010
    Link to this post
    Sorry Ivan,

    I have a slight issue but not sure how to go about fixing it.  I used the http module which works great on the front end website, but for some reason destorys the sitefinity admin, now i have tried to use the do not move meta flag of the http module, and the viewstate stays in the same place but the page is all over the place and no javascript seems to work.

    Attached is an image, can you think of any reason why this would happen?

    Rob
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    17 Mar 2010
    Link to this post
    Hello Roberto Modica,

    In the custom HttpModule, inside beginRequest, check whether you are in the backend and not execute the code you use to move the viewstate.

    public class HttpModule : IHttpModule
    {
        public HttpModule()
        {
     
        }
     
        #region IHttpModule Members
     
        public void Dispose()
        {
             
        }
     
        public void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }
     
        void context_BeginRequest(object sender, EventArgs e)
        {
            HttpContext context = HttpContext.Current;
            string path = context.Request.Url.AbsolutePath.ToString();
            if(!path.Contains("/sitefinity"))
            {
                //your logic here
                // you are not in the backend.
            }
        }
     
        #endregion
    }


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
7 posts, 1 answered