DistributedSession Constructors

Definition

Overloads

DistributedSession(IDistributedCache, String, TimeSpan, Func<Boolean>, ILoggerFactory, Boolean)

C#
public DistributedSession (Microsoft.Extensions.Caching.Distributed.IDistributedCache cache, string sessionKey, TimeSpan idleTimeout, Func<bool> tryEstablishSession, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, bool isNewSessionKey);

Parameters

sessionKey
String
idleTimeout
TimeSpan
tryEstablishSession
Func<Boolean>
loggerFactory
ILoggerFactory
isNewSessionKey
Boolean

Applies to

ASP.NET Core 1.1 dan ASP.NET Core 1.0
Produk Versi
ASP.NET Core 1.0, 1.1

DistributedSession(IDistributedCache, String, TimeSpan, TimeSpan, Func<Boolean>, ILoggerFactory, Boolean)

Source:
DistributedSession.cs
Source:
DistributedSession.cs
Source:
DistributedSession.cs

Initializes a new instance of DistributedSession.

C#
public DistributedSession (Microsoft.Extensions.Caching.Distributed.IDistributedCache cache, string sessionKey, TimeSpan idleTimeout, TimeSpan ioTimeout, Func<bool> tryEstablishSession, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, bool isNewSessionKey);

Parameters

cache
IDistributedCache

The IDistributedCache used to store the session data.

sessionKey
String

A unique key used to lookup the session.

idleTimeout
TimeSpan

How long the session can be inactive (e.g. not accessed) before it will expire.

ioTimeout
TimeSpan

The maximum amount of time LoadAsync(CancellationToken) and CommitAsync(CancellationToken) are allowed take.

tryEstablishSession
Func<Boolean>

A callback invoked during Set(String, Byte[]) to verify that modifying the session is currently valid. If the callback returns false, Set(String, Byte[]) throws an InvalidOperationException. SessionMiddleware provides a callback that returns false if the session was not established prior to sending the response.

loggerFactory
ILoggerFactory

The ILoggerFactory.

isNewSessionKey
Boolean

true if establishing a new session; false if resuming a session.

Applies to

ASP.NET Core 9.0 dan versi lain
Produk Versi
ASP.NET Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0