Dela via


ISession Interface

Definition

Stores user data while the user browses a web application. Session state uses a store maintained by the application to persist data across requests from a client. The session data is backed by a cache and considered ephemeral data.

public interface class ISession
public interface ISession
type ISession = interface
Public Interface ISession
Derived

Properties

Id

A unique identifier for the current session. This is not the same as the session cookie since the cookie lifetime may not be the same as the session entry lifetime in the data store.

IsAvailable

Indicates whether the current session loaded successfully. Accessing this property before the session is loaded will cause it to be loaded inline.

Keys

Enumerates all the keys, if any.

Methods

Clear()

Remove all entries from the current session, if any. The session cookie is not removed.

CommitAsync()

Store the session in the data store. This may throw if the data store is unavailable.

CommitAsync(CancellationToken)

Store the session in the data store. This may throw if the data store is unavailable.

LoadAsync()

Load the session from the data store. This may throw if the data store is unavailable.

LoadAsync(CancellationToken)

Load the session from the data store. This may throw if the data store is unavailable.

Remove(String)

Remove the given key from the session if present.

Set(String, Byte[])

Set the given key and value in the current session. This will throw if the session was not established prior to sending the response.

TryGetValue(String, Byte[])

Retrieve the value of the given key, if present.

Extension Methods

Get(ISession, String)

Gets a byte-array value from ISession.

GetInt32(ISession, String)

Gets an int value from ISession.

GetString(ISession, String)

Gets a string value from ISession.

SetInt32(ISession, String, Int32)

Sets an int value in the ISession.

SetString(ISession, String, String)

Sets a String value in the ISession.

Applies to