共用方式為


MsalSessionTokenCacheProvider Class

Definition

An implementation of token cache for confidential clients backed by an HTTP session.

public class MsalSessionTokenCacheProvider : Microsoft.Identity.Web.TokenCacheProviders.MsalAbstractTokenCacheProvider, IDisposable
type MsalSessionTokenCacheProvider = class
    inherit MsalAbstractTokenCacheProvider
    interface IDisposable
Public Class MsalSessionTokenCacheProvider
Inherits MsalAbstractTokenCacheProvider
Implements IDisposable
Inheritance
MsalSessionTokenCacheProvider
Implements

Remarks

For this session cache to work effectively, the ASP.NET Core session has to be configured properly. The latest guidance is provided at https://learn.microsoft.com/aspnet/core/fundamentals/app-state.

In the method public void ConfigureServices(IServiceCollection services) in Startup.cs, add the following:

services.AddSession(option =>
{
    option.Cookie.IsEssential = true;
});

In the method public void Configure(IApplicationBuilder app, IHostingEnvironment env) in Startup.cs, add the following:

app.UseSession(); // Before UseMvc()

Constructors

MsalSessionTokenCacheProvider(ISession, ILogger<MsalSessionTokenCacheProvider>)

MSAL Token cache provider constructor.

Methods

ClearAsync(String)

Clear the cache.

(Inherited from MsalAbstractTokenCacheProvider)
Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

GetSuggestedCacheKey(TokenCacheNotificationArgs)

Method to be overridden by concrete cache serializers to express the suggested key.

(Inherited from MsalAbstractTokenCacheProvider)
Initialize(ITokenCache)

Initializes the token cache serialization.

(Inherited from MsalAbstractTokenCacheProvider)
InitializeAsync(ITokenCache)

Initializes the token cache serialization.

(Inherited from MsalAbstractTokenCacheProvider)
OnBeforeWriteAsync(TokenCacheNotificationArgs)

If you want to ensure that no concurrent write takes place, use this notification to place a lock on the entry.

(Inherited from MsalAbstractTokenCacheProvider)
ReadCacheBytesAsync(String, CacheSerializerHints)

Read a blob representing the token cache from its key.

ReadCacheBytesAsync(String)

Read a blob representing the token cache from its key.

RemoveKeyAsync(String, CacheSerializerHints)

Method to be overridden by concrete cache serializers to remove an entry from the cache.

(Inherited from MsalAbstractTokenCacheProvider)
RemoveKeyAsync(String)

Removes a cache described by its key.

WriteCacheBytesAsync(String, Byte[], CacheSerializerHints)

Method to be overridden by concrete cache serializers to write the cache bytes.

(Inherited from MsalAbstractTokenCacheProvider)
WriteCacheBytesAsync(String, Byte[])

Writes the token cache identified by its key to the serialization mechanism.

Applies to