Export (0) Print
Expand All

SessionPageStatePersister Class

Stores ASP.NET page view state on the Web server.

System.Object
  System.Web.UI.PageStatePersister
    System.Web.UI.SessionPageStatePersister

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public class SessionPageStatePersister : PageStatePersister

The SessionPageStatePersister type exposes the following members.

  NameDescription
Public methodSessionPageStatePersisterInitializes a new instance of the SessionPageStatePersister class.
Top

  NameDescription
Public propertyControlStateGets or sets an object that represents the data that controls contained by the current Page object use to persist across HTTP requests to the Web server. (Inherited from PageStatePersister.)
Protected propertyPageGets or sets the Page object that the view state persistence mechanism is created for. (Inherited from PageStatePersister.)
Protected propertyStateFormatterGets an IStateFormatter object that is used to serialize and deserialize the state information contained in the ViewState and ControlState properties during calls to the Save and Load methods. (Inherited from PageStatePersister.)
Public propertyViewStateGets or sets an object that represents the data that controls contained by the current Page object use to persist across HTTP requests to the Web server. (Inherited from PageStatePersister.)
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodLoadDeserializes and loads persisted state from the server-side session object when a Page object initializes its control hierarchy. (Overrides PageStatePersister.Load().)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSaveSerializes any object state contained in the ViewState or the ControlState property and writes the state to the session object. (Overrides PageStatePersister.Save().)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

ASP.NET pages can store Page state information between the inherently stateless HTTP request and response required to process and serve any Web page. This state is called "view state."

The default ASP.NET persistence mechanism is to store view state on the client using the HiddenFieldPageStatePersister class. Storing view state and data with each HTTP request and response performs well in general and is important in large Web farm scenarios because it does not matter which Web server services the request: the page state is available in the current context for the server to accurately render the page.

In scenarios where pages are served to small devices that have limited client-side resources or use a markup language that does not support a hidden field element, it is required to store view state on the server. Several ASP.NET device page adapters override the GetStatePersister method to return a SessionPageStatePersister object that stores page state on the server in the session object associated with the client.

The following code example demonstrates how you can write a PageAdapter class to return an instance of the SessionPageStatePersister class instead of the default HiddenFieldPageStatePersister class to save view state to the server-side session object.


namespace Samples.AspNet.CS {

    using System.Web.UI;

    public class MyPageAdapter : System.Web.UI.Adapters.PageAdapter {

        public override PageStatePersister GetStatePersister() {
            return new SessionPageStatePersister(Page);
        }
    }
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft