SessionStateItemCollection.Deserialize Method (BinaryReader)

 
System_CAPS_noteNote

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

Creates a SessionStateItemCollection collection from a storage location that is written to using the Serialize method.

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

public static SessionStateItemCollection Deserialize(
	BinaryReader reader
)

Parameters

reader
Type: System.IO.BinaryReader

The BinaryReader used to read the serialized collection from a stream or encoded string.

Return Value

Type: System.Web.SessionState.SessionStateItemCollection

A SessionStateItemCollection collection populated with the contents from a storage location that is written to using the Serialize method.

Exception Condition
HttpException

The session state information is invalid or corrupted

The Deserialize method can be used to read the contents of a SessionStateItemCollection collection from the session store.

To write the contents of a SessionStateItemCollection object to the session store, use the Serialize method.

The following code example creates a SessionStateItemCollection collection from a file that was created using the Serialize method.

System.IO.BinaryReader reader = new System.IO.BinaryReader(
  System.IO.File.Open(Server.MapPath("session_collection.bin"), System.IO.FileMode.Open));

SessionStateItemCollection sessionItems = SessionStateItemCollection.Deserialize(reader);

for (int i = 0; i < sessionItems.Count; i++)
  Response.Write("sessionItems[" + i + "] = " + sessionItems[i].ToString() + "<br />");

.NET Framework
Available since 2.0
Return to top
Show: