SessionPageStatePersister Class
Assembly: System.Web (in system.web.dll)
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.
package Samples.AspNet.JSL;
import System.Web.UI.*;
public class MyPageAdapter extends System.Web.UI.Adapters.PageAdapter
{
public PageStatePersister GetStatePersister()
{
return new SessionPageStatePersister(this.get_Page());
} //GetStatePersister
} //MyPageAdapter
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.