SessionStateItemCollection.Deserialize(BinaryReader) Method

Definition

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

C#
public static System.Web.SessionState.SessionStateItemCollection Deserialize(System.IO.BinaryReader reader);

Parameters

reader
BinaryReader

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

Returns

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

Exceptions

The session state information is invalid or corrupted

Examples

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

C#
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 />");

Remarks

Важливо

Calling this method with untrusted data is a security risk. Call this method only with trusted data. For more information, see Validate All Inputs.

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.

Applies to

Продукт Версії
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also