已包装 ASP.NET Core 会话状态

此实现包装 ASP.NET Core 上提供的会话,以便它可以与适配器一起使用。 该会话将使用与 Microsoft.AspNetCore.Http.ISession 相同的后备存储,但会为其成员提供强类型访问权限。

ASP.NET Core 的配置类似于以下内容:

builder.Services.AddSystemWebAdapters()
    .AddJsonSessionSerializer(options =>
    {
        // Serialization/deserialization requires each session key to be registered to a type
        options.RegisterKey<int>("test-value");
        options.RegisterKey<SessionDemoModel>("SampleSessionItem");
    })
    .WrapAspNetCoreSession();

框架应用无需任何更改即可启用此行为。