ASP.NET Session State (not for ASP.NET Core)
Перейти к файлу
Steve Molloy 99e0015a7e
Allow pre-provisioned throughput (#68)
* Allowing to use provisioned throughput by setting offerThroughput value to "0".

* Round-about way of re-writing this onto current main, but I wanted to keep the original PR commit in the list for credit.

---------

Co-authored-by: Al Baymar <abaymar@aras.com>
2023-01-27 17:21:42 -08:00
.nuget Update for build pipeline changes (#64) 2023-01-25 10:28:56 -08:00
docs Allow pre-provisioned throughput (#68) 2023-01-27 17:21:42 -08:00
src Allow pre-provisioned throughput (#68) 2023-01-27 17:21:42 -08:00
test Move from JSON.Net to Sys.Text.Json (#67) 2023-01-27 15:45:15 -08:00
tools Clean nit. 2023-01-27 16:15:06 -08:00
.gitignore Solution cleanup (#23) 2019-06-13 18:10:46 -07:00
CODE-OF-CONDUCT.md Link Code of Conduct (#38) 2020-04-09 12:53:28 -07:00
CONTRIBUTING.md update cla link (#6) 2018-04-05 13:11:04 -07:00
License.txt update according to the feedback (#5) 2018-04-04 13:22:04 -07:00
Microsoft.Aspnet.SessionState.sln Update for build pipeline changes (#64) 2023-01-25 10:28:56 -08:00
MicrosoftAspNetSessionState.msbuild 21 more cosmos db partitions by default (#24) 2019-06-18 17:54:42 -07:00
Readme.md Fixes for pr60 (#66) 2023-01-27 11:29:47 -08:00
build.cmd Solution cleanup (#23) 2019-06-13 18:10:46 -07:00
clean.cmd Solution cleanup (#23) 2019-06-13 18:10:46 -07:00

Readme.md

Introduction

SessionStateModule is ASP.NETs default session-state handler which retrieves session data and writes it to the session-state store. It already operates asynchronously when acquiring the request state, but it doesnt support async read/write to the session-state store. In the .NET Framework 4.6.2 release, we introduced a new interface named ISessionStateModule to enable this scenario. You can find more details on this blog post.

How to build

  1. Open a VS developer command prompt
  2. Run build.cmd. This will build Nuget package and run all the unit tests.
  3. All the build artifacts will be under aspnetsessionstate\bin\Release\ folder.

How to contribute

Information on contributing to this repo is in the Contributing Guide.

How to use

  1. Update your web.config to remove the old session state module and register the new one:
  <system.webServer>
    <modules>
      <!-- remove the existing Session state module -->
      <remove name="Session" />
      <add name="Session" preCondition="integratedMode" type="Microsoft.AspNet.SessionState.SessionStateModuleAsync, Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral" />
    </modules>
  </system.webServer>
  1. Add one of the new providers to the <sessionState> section of your web.config:
  <sessionState cookieless="false" regenerateExpiredSessionId="true" mode="Custom" customProvider="YourProviderName">
    <providers>
      <add name="YourProviderName" [providerOptions] type="Provider, ProviderAssembly, Version=, Culture=neutral, PublicKeyToken=" />
    </providers>
  </sessionState>

The specific settings available for the new session state module and providers are detailed in their respective doc pages.

Module and Providers contained here

V1.2 Updates:

  • ⚠️ Breaking Change - CosmosDB partition-related parameters are ignored. All containers use /id as the partition path now. Using an existing container with a different partition key path will result in exceptions.

    The original design around partition use in the CosmosDB provider was influenced by experience with the older SQL partition paradigms. There was an effort to enable them for scalability, but keep them reasonable for managability. In reality, CosmosDB encourages the use of as many "logical" partitions as can be used so long as they make sense. The complexity of managing and scaling is all handled magically by CosmosDB.

    The most logical partition field for session state is the session ID. The CosmosDB provider has been updated to alway use "/id" as the partition key path with the full session ID as the partition value. Pre-existing containers that use a different partition key path (which is any that opted into using partitions previously) will need to migrate to a container that uses "/id" as the partition key path. The data is all still good - although, the old partition key path can be dropped when migrating. There is unfortunately no way to simply update the partition key path on an existing container right now. This blog post is a guide for migrating to a new container with the correct partition key path.

  • CosmosDB collectionId is now containerId in keeping with the updated terminology from the CosmosDB offering. Please use the updated parameter name when configuring your provider. (The old name will continue to work just the same.)
  • CosmosDB connectionProtocol is obsolete. It will not cause errors to have it in configuration, but it is ignored. The current CosmosDB SDK chooses the protocol based on connection mode.