IStateFormatter Interface


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Defines methods that a type implements to serialize and deserialize an object graph.

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

type IStateFormatter = interface end


Deserializes an object state graph from its serialized string form.


Serializes ASP.NET Web server control state to string form.

The IStateFormatter interface defines methods that a type can implement to serialize and deserialize the state that an ASP.NET Web server control maintains in its ViewState property. This infrastructure is used by classes that derive from the PageStatePersister class to maintain an ASP.NET page's state between requests. By default, ASP.NET page state is serialized and deserialized by an instance of the ObjectStateFormatter class; however, site and adapter developers can implement the IStateFormatter interface on their own types to perform this work.

For more information about Web server control state management and view state, see ASP.NET State Management Overview and Dynamic Web Server Controls and View State.

The following code example demonstrates how to create a PageStatePersister object that saves view and control state to a stream on the Web server. The StreamPageStatePersister class demonstrates how to override the Load and Save methods to extract and save page state information. These methods use the IStateFormatter interface inherited from the PageStatePersister class to serialize and deserialize view state. This code example is part of a larger example provided for the PageStatePersister class.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top