├── .gitignore
├── .nuget
├── NuGet.Config
├── NuGet.exe
└── NuGet.targets
├── CODE-OF-CONDUCT.md
├── CONTRIBUTING.md
├── License.txt
├── Microsoft.Aspnet.SessionState.sln
├── MicrosoftAspNetSessionState.msbuild
├── Readme.md
├── SECURITY.md
├── azure-pipeline
└── azure-pipeline.yml
├── build.cmd
├── clean.cmd
├── docs
├── CosmosDBSessionStateProviderAsync.md
├── SessionStateModule.md
└── SqlSessionStateProviderAsync.md
├── src
├── CosmosDBSessionStateProviderAsync
│ ├── CosmosDBSessionStateProviderAsync.cs
│ ├── Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Resources
│ │ ├── SR.Designer.cs
│ │ └── SR.resx
│ ├── SessionStateActionsConverter.cs
│ ├── SessionStateItem.cs
│ ├── SystemTextJsonSerializer.cs
│ └── TimeSpanConverter.cs
├── SessionStateModule
│ ├── AppSettings.cs
│ ├── InProcSessionStateStoreAsync.cs
│ ├── Microsoft.AspNet.SessionState.SessionStateModule.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Resources
│ │ ├── SR.Designer.cs
│ │ └── SR.resx
│ ├── SessionEventSource.cs
│ ├── SessionOnEndTarget.cs
│ ├── SessionStateItemCollections.cs
│ ├── SessionStateModuleAsync.cs
│ ├── SessionStateStoreProviderAsyncBase.cs
│ ├── StateSerializationUtil.cs
│ └── TaskAsyncHelper.cs
├── SqlSessionStateProviderAsync
│ ├── ISqlSessionStateRepository.cs
│ ├── Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Resources
│ │ ├── SR.Designer.cs
│ │ └── SR.resx
│ ├── SqlCommandExtension.cs
│ ├── SqlCommandHelper.cs
│ ├── SqlFxCompatSessionStateRepository.cs
│ ├── SqlInMemoryTableSessionStateRepository.cs
│ ├── SqlParameterCollectionExtension.cs
│ ├── SqlSessionStateProviderAsync.cs
│ ├── SqlSessionStateRepository.cs
│ ├── SqlSessionStateRepositoryUtil.cs
│ └── StringExtensions.cs
└── packages
│ ├── CosmosDBSessionStateProviderAsync.nupkg
│ ├── Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.nuproj
│ ├── Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.nuspec
│ └── content
│ │ └── Net462
│ │ ├── web.config.install.xdt
│ │ └── web.config.uninstall.xdt
│ ├── Packages.csproj
│ ├── SessionStateModule.nupkg
│ ├── Microsoft.AspNet.SessionState.SessionStateModule.nuproj
│ ├── Microsoft.AspNet.SessionState.SessionStateModule.nuspec
│ └── content
│ │ └── Net462
│ │ ├── web.config.install.xdt
│ │ └── web.config.uninstall.xdt
│ ├── SqlSessionStateProviderAsync.nupkg
│ ├── Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.nuproj
│ ├── Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.nuspec
│ └── content
│ │ └── Net462
│ │ ├── web.config.install.xdt
│ │ └── web.config.uninstall.xdt
│ └── assets
│ └── dotnet-icon.png
├── test
├── Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.Test
│ ├── 35MSSharedLib1024.snk
│ ├── CosmosDBSessionStateProviderAsyncTest.cs
│ ├── Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.Test.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── SessionStateItemTest.cs
├── Microsoft.AspNet.SessionState.SessionStateModuleAsync.Test
│ ├── InProcSessionStateStoreAsync.cs
│ ├── Microsoft.AspNet.SessionState.SessionStateModuleAsync.Test.csproj
│ └── Properties
│ │ └── AssemblyInfo.cs
└── Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test
│ ├── Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test.csproj
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── SqlCommandHelperTest.cs
│ └── SqlSessionStateAsyncProviderTest.cs
└── tools
├── .verif.whitelist
├── 35MSSharedLib1024.snk
├── CosmosDBSessionStateProviderAsync.settings.targets
├── MicrosoftAspNetSessionState.settings.targets
├── NuGet.targets
├── NuGetProj.targets
├── NuProj.Tasks.dll
├── SessionStateModule.settings.targets
├── SqlSessionStateProviderAsync.settings.targets
├── signing.targets
└── version.targets
/.gitignore:
--------------------------------------------------------------------------------
1 | [Oo]bj/
2 | [Bb]in/
3 | .vs/
4 | msbuild.*
5 | obj/
6 | /packages/
7 | .binaries/
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/AspNetSessionState/97428df0dbe5aac2e93f394cf08afffb45382c4a/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 |
32 |
33 |
34 |
35 | $(SolutionDir).nuget
36 |
37 |
38 |
39 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config
40 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config
41 |
42 |
43 |
44 | $(MSBuildProjectDirectory)\packages.config
45 | $(PackagesProjectConfig)
46 |
47 |
48 |
49 |
50 | $(NuGetToolsPath)\NuGet.exe
51 | @(PackageSource)
52 |
53 | "$(NuGetExePath)"
54 | mono --runtime=v4.0.30319 $(NuGetExePath)
55 |
56 | $(TargetDir.Trim('\\'))
57 |
58 | -RequireConsent
59 | -NonInteractive
60 |
61 | "$(SolutionDir)"
62 | "$(SolutionDir)"
63 |
64 |
65 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
66 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
67 |
68 |
69 |
70 | RestorePackages;
71 | $(BuildDependsOn);
72 |
73 |
74 |
75 |
76 | $(BuildDependsOn);
77 | BuildPackage;
78 |
79 |
80 |
81 |
82 |
83 |
84 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
99 |
100 |
103 |
104 |
105 |
106 |
108 |
109 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
141 |
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/CODE-OF-CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Code of Conduct
2 |
3 | This project has adopted the code of conduct defined by the Contributor Covenant
4 | to clarify expected behavior in our community.
5 |
6 | For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).
7 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to contribute
2 |
3 | One of the easiest ways to contribute is to participate in discussions and discuss issues. You can also contribute by submitting pull requests with code changes.
4 |
5 |
6 | ## General feedback and discussions?
7 | Please start a discussion on the [Issue tracker](https://github.com/aspnet/AspNetSessionState/issues).
8 |
9 |
10 | ## Bugs and feature requests?
11 | For non-security related bugs please log a new issue according to the [Functional bug template](https://github.com/aspnet/AspNetSessionState/wiki/Functional-bug-template).
12 |
13 |
14 |
15 | ## Reporting security issues and bugs
16 | Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/ff852094.aspx).
17 |
18 |
19 | ## Contributing code and content
20 |
21 | **Obtaining the source code**
22 |
23 | If you are an outside contributer, please fork the repository. See the GitHub documentation for [forking a repo](https://help.github.com/articles/fork-a-repo/) if you have any questions about this.
24 |
25 | **Submitting a pull request**
26 |
27 | You will need to sign a [Contributor License Agreement](https://cla.opensource.microsoft.com//) when submitting your pull request. To complete the Contributor License Agreement (CLA), you will need to follow the instructions provided by the CLA bot when you send the pull request. This needs to only be done once for any Microsoft OSS project.
28 |
29 | If you don't know what a pull request is read this article: https://help.github.com/articles/using-pull-requests. Make sure the respository can build and all tests pass.
30 |
31 | **Commit/Pull Request Format**
32 |
33 | ```
34 | Summary of the changes (Less than 80 chars)
35 | - Detail 1
36 | - Detail 2
37 |
38 | Addresses #bugnumber (in this specific format)
39 | ```
40 |
41 | **Tests**
42 |
43 | - Tests need to be provided for every bug/feature that is completed.
44 | - Tests only need to be present for issues that need to be verified by QA (e.g. not tasks)
45 | - If there is a scenario that is far too hard to test there does not need to be a test for it.
46 | - "Too hard" is determined by the team as a whole.
47 |
48 | **Feedback**
49 |
50 | Your pull request will now go through extensive checks by the subject matter experts on our team. Please be patient; we have hundreds of pull requests across all of our repositories. Update your pull request according to feedback until it is approved by one of the ASP.NET team members. After that, one of our team members will add the pull request to **dev**.
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) Microsoft Corporation
2 | All rights reserved.
3 |
4 | MIT License
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | this software and associated documentation files (the ""Software""), to deal in
8 | the Software without restriction, including without limitation the rights to
9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | the Software, and to permit persons to whom the Software is furnished to do so,
11 | subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/Microsoft.Aspnet.SessionState.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.4.33213.308
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{58E8143E-86D8-4CA3-AAC3-1CF253D91207}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{93AD624B-85A6-4EE9-B40E-42914D40C0CF}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync", "src\SqlSessionStateProviderAsync\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.csproj", "{493B0482-572A-4465-BD52-4094351C2647}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync", "src\CosmosDBSessionStateProviderAsync\Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.csproj", "{4CFB2896-D5C1-4E96-A3DA-D57C58539209}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SessionState.SessionStateModule", "src\SessionStateModule\Microsoft.AspNet.SessionState.SessionStateModule.csproj", "{7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test", "test\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test.csproj", "{CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}"
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.Test", "test\Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.Test\Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.Test.csproj", "{2AF89ACA-3545-432D-8D99-C5230E8643A8}"
19 | EndProject
20 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{78F4C27F-37B4-4D27-B198-F601359EC691}"
21 | ProjectSection(SolutionItems) = preProject
22 | tools\CosmosDBSessionStateProviderAsync.settings.targets = tools\CosmosDBSessionStateProviderAsync.settings.targets
23 | tools\MicrosoftAspNetSessionState.settings.targets = tools\MicrosoftAspNetSessionState.settings.targets
24 | tools\SessionStateModule.settings.targets = tools\SessionStateModule.settings.targets
25 | tools\SqlSessionStateProviderAsync.settings.targets = tools\SqlSessionStateProviderAsync.settings.targets
26 | EndProjectSection
27 | EndProject
28 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Packages", "src\packages\Packages.csproj", "{7EC5863F-7FF1-41C7-A384-8FFF81531E7A}"
29 | ProjectSection(ProjectDependencies) = postProject
30 | {7238F90D-3BCE-4F40-A5BA-EA36AD484BD6} = {7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}
31 | {493B0482-572A-4465-BD52-4094351C2647} = {493B0482-572A-4465-BD52-4094351C2647}
32 | {4CFB2896-D5C1-4E96-A3DA-D57C58539209} = {4CFB2896-D5C1-4E96-A3DA-D57C58539209}
33 | EndProjectSection
34 | EndProject
35 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{3626D7CE-EDDB-4B2A-83E1-A1B69FDB874A}"
36 | ProjectSection(SolutionItems) = preProject
37 | docs\CosmosDBSessionStateProviderAsync.md = docs\CosmosDBSessionStateProviderAsync.md
38 | Readme.md = Readme.md
39 | docs\SessionStateModule.md = docs\SessionStateModule.md
40 | docs\SqlSessionStateProviderAsync.md = docs\SqlSessionStateProviderAsync.md
41 | EndProjectSection
42 | EndProject
43 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SessionState.SessionStateModuleAsync.Test", "test\Microsoft.AspNet.SessionState.SessionStateModuleAsync.Test\Microsoft.AspNet.SessionState.SessionStateModuleAsync.Test.csproj", "{AD91AAF5-3B57-4C8C-9A39-92FB578AF317}"
44 | EndProject
45 | Global
46 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
47 | Debug|Any CPU = Debug|Any CPU
48 | Release|Any CPU = Release|Any CPU
49 | EndGlobalSection
50 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
51 | {493B0482-572A-4465-BD52-4094351C2647}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52 | {493B0482-572A-4465-BD52-4094351C2647}.Debug|Any CPU.Build.0 = Debug|Any CPU
53 | {493B0482-572A-4465-BD52-4094351C2647}.Release|Any CPU.ActiveCfg = Release|Any CPU
54 | {493B0482-572A-4465-BD52-4094351C2647}.Release|Any CPU.Build.0 = Release|Any CPU
55 | {4CFB2896-D5C1-4E96-A3DA-D57C58539209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
56 | {4CFB2896-D5C1-4E96-A3DA-D57C58539209}.Debug|Any CPU.Build.0 = Debug|Any CPU
57 | {4CFB2896-D5C1-4E96-A3DA-D57C58539209}.Release|Any CPU.ActiveCfg = Release|Any CPU
58 | {4CFB2896-D5C1-4E96-A3DA-D57C58539209}.Release|Any CPU.Build.0 = Release|Any CPU
59 | {7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
60 | {7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
61 | {7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
62 | {7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}.Release|Any CPU.Build.0 = Release|Any CPU
63 | {CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
64 | {CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
65 | {CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
66 | {CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}.Release|Any CPU.Build.0 = Release|Any CPU
67 | {2AF89ACA-3545-432D-8D99-C5230E8643A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
68 | {2AF89ACA-3545-432D-8D99-C5230E8643A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
69 | {2AF89ACA-3545-432D-8D99-C5230E8643A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
70 | {2AF89ACA-3545-432D-8D99-C5230E8643A8}.Release|Any CPU.Build.0 = Release|Any CPU
71 | {7EC5863F-7FF1-41C7-A384-8FFF81531E7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
72 | {7EC5863F-7FF1-41C7-A384-8FFF81531E7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
73 | {7EC5863F-7FF1-41C7-A384-8FFF81531E7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
74 | {7EC5863F-7FF1-41C7-A384-8FFF81531E7A}.Release|Any CPU.Build.0 = Release|Any CPU
75 | {AD91AAF5-3B57-4C8C-9A39-92FB578AF317}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76 | {AD91AAF5-3B57-4C8C-9A39-92FB578AF317}.Debug|Any CPU.Build.0 = Debug|Any CPU
77 | {AD91AAF5-3B57-4C8C-9A39-92FB578AF317}.Release|Any CPU.ActiveCfg = Release|Any CPU
78 | {AD91AAF5-3B57-4C8C-9A39-92FB578AF317}.Release|Any CPU.Build.0 = Release|Any CPU
79 | EndGlobalSection
80 | GlobalSection(SolutionProperties) = preSolution
81 | HideSolutionNode = FALSE
82 | EndGlobalSection
83 | GlobalSection(NestedProjects) = preSolution
84 | {493B0482-572A-4465-BD52-4094351C2647} = {58E8143E-86D8-4CA3-AAC3-1CF253D91207}
85 | {4CFB2896-D5C1-4E96-A3DA-D57C58539209} = {58E8143E-86D8-4CA3-AAC3-1CF253D91207}
86 | {7238F90D-3BCE-4F40-A5BA-EA36AD484BD6} = {58E8143E-86D8-4CA3-AAC3-1CF253D91207}
87 | {CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2} = {93AD624B-85A6-4EE9-B40E-42914D40C0CF}
88 | {2AF89ACA-3545-432D-8D99-C5230E8643A8} = {93AD624B-85A6-4EE9-B40E-42914D40C0CF}
89 | {7EC5863F-7FF1-41C7-A384-8FFF81531E7A} = {58E8143E-86D8-4CA3-AAC3-1CF253D91207}
90 | {AD91AAF5-3B57-4C8C-9A39-92FB578AF317} = {93AD624B-85A6-4EE9-B40E-42914D40C0CF}
91 | EndGlobalSection
92 | GlobalSection(ExtensibilityGlobals) = postSolution
93 | SolutionGuid = {4853AD21-0DCE-40D8-A3B9-19081B71C364}
94 | EndGlobalSection
95 | EndGlobal
96 |
--------------------------------------------------------------------------------
/MicrosoftAspNetSessionState.msbuild:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | ## Introduction
2 | SessionStateModule is ASP.NET’s 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 doesn’t 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](https://blogs.msdn.microsoft.com/webdev/2016/09/29/introducing-the-asp-net-async-sessionstate-module/).
3 |
4 | ## How to build
5 | 1. Open a [VS developer command prompt](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs)
6 | 2. Run build.cmd. This will build Nuget package and run all the unit tests.
7 | 3. All the build artifacts will be under aspnetsessionstate\bin\Release\ folder.
8 |
9 | ## How to contribute
10 | Information on contributing to this repo is in the [Contributing Guide](CONTRIBUTING.md).
11 |
12 | ## How to use
13 | 1. Update your web.config to remove the old session state module and register the new one:
14 | ```xml
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | ```
23 | 2. Add one of the new providers to the `` section of your web.config:
24 | ```xml
25 |
26 |
27 |
28 |
29 |
30 | ```
31 | The specific settings available for the new session state module and providers are detailed in their respective doc pages.
32 |
33 | ## Module and Providers contained here
34 | - [Microsoft.AspNet.SessionState.SessionStateModule](docs/SessionStateModule.md)
35 | - [Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync](docs/SqlSessionStateProviderAsync.md)
36 | - [Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync](docs/CosmosDBSessionStateProviderAsync.md)
37 |
38 |
39 | ## V2.1 Updates:
40 | * New `ISessionStateItemCollection` implementations for concurrent access. The `SessionStateItemCollection` that comes in the framework is not thread-safe and can cause issues when multiple threads are trying to access the same session state, which is something that is allowed with this package and the `AllowConcurrentRequestsPerSession` setting. When this feature is enabled, the providers in this repo will use the new thread-safe implementations: `ConcurrentNonSerializingSessionStateItemCollection` for the In-Proc provider, since it does not need to serialize session state data, and `ConcurrentSessionStateItemCollection` for the SQL and CosmosDB providers, since they do need to serialize session state data. This latter implementation is as direct of a port from the .Net framework as possible while fixing the concurrency issue with the original implementaiton.
41 | ## V2.0 Updates:
42 | * :warning: ***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. `partitionKeyPath` and `partitionNumUsedByProvider` are now ignored.
43 | > 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.
44 | >
45 | > 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](https://devblogs.microsoft.com/cosmosdb/how-to-change-your-partition-key/) is a guide for migrating to a new container with the correct partition key path.
46 | * :warning: ***Potential Breaking Change*** - Added `managedHandler` precondition to module configuration. The old in-box session module used this and it is a reasonable default for avoiding traffic jams. It can be removed from web.config if session is required for non-managed handlers as well.
47 | * :warning: ***Action Required*** Sql provider `repositoryType` - This new setting provides a little more flexibility for repository configuration beyond a single boolean for in-memory optimized tables. Possible values are `SqlServer|InMemory|InMemoryDurable|FrameworkCompat`. Read about what each configuration is at our [SqlSessionStateProviderAsync](docs/SqlSessionStateProviderAsync.md) doc page.
48 |
49 | > The mechanics of nuget package upgrade results in removing old elements and re-adding the boiler-plate elements in configuration. To restore In-Memory functionality, set 'repositoryType' to `InMemory`. To continue using an existing non-memory-optimized table without stored procedures, set 'RespositoryType' to `FrameworkCompat`. The recommendation is to update to the new table schema and use stored procedures with `SqlServer`, but this will ignore existing sessions in previously existing tables.
50 | * Moved to use `Microsoft.Data.SqlClient` instead of old `System.Data.SqlClient`. This allows for more modern features such as Token Authorization.
51 | * Added `skipKeepAliveWhenUnused` to all providers. This setting will skip the call to update expiration time on requests that did not read or write session state. This is setting is used at the module level, and is thus exists on all providers. The default is "false" to maintain compatibility. But certain applications (like MVC) where there can be an abundance of requests processed that never even look at session state could benefit from setting this to "true" to reduce the use of and contention within the session state store. Setting this to "true" does mean that a session needs to be used (not necessarily updated, but at least requested/queried) to stay alive.
52 | * The Sql provider's `useInMemoryTable` is deprecated. It will continue to be respected in the absence of `repositoryType`, but is overridden by that setting if given.
53 | * Sql provider `sessionTableName` - A new setting that allows users to target a specific table in their database rather than being forced to use the default table names.
54 | * 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.)
55 | * Added CosmosDB `consistencyLevel` to allow using a different [Consistency Level](https://learn.microsoft.com/en-us/azure/cosmos-db/consistency-levels) with the CosmosClient.
56 | * 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](https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/sdk-connection-modes).
57 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | The .NET Core and ASP.NET Core support policy, including supported versions can be found at the [.NET Core Support Policy Page](https://dotnet.microsoft.com/platform/support/policy/dotnet-core).
6 |
7 | ## Reporting a Vulnerability
8 |
9 | Security issues and bugs should be reported privately to the Microsoft Security Response Center (MSRC), either by emailing secure@microsoft.com or via the portal at https://msrc.microsoft.com.
10 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your
11 | original message. Further information, including the MSRC PGP key, can be found in the [MSRC Report an Issue FAQ](https://www.microsoft.com/en-us/msrc/faqs-report-an-issue).
12 |
13 | Reports via MSRC may qualify for the .NET Core Bug Bounty. Details of the .NET Core Bug Bounty including terms and conditions are at [https://aka.ms/corebounty](https://aka.ms/corebounty).
14 |
15 | Please do not open issues for anything you think might have a security implication.
16 |
--------------------------------------------------------------------------------
/azure-pipeline/azure-pipeline.yml:
--------------------------------------------------------------------------------
1 | # This Yaml Document has been converted by ESAI Yaml Pipeline Conversion Tool.
2 | # Please make sure to check all the converted content, it is your team's responsibility to make sure that the pipeline is still valid and functions as expected.
3 | # The SBOM tasks have been removed because they are not required for the unofficial template.
4 | # You can manually enable SBOM in the unofficial template if needed, othewise its automatically enabled when using official template. https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/1es-pipeline-templates/features/sbom
5 | # This pipeline will be extended to the MicroBuild template
6 | # The Task 'PublishBuildArtifacts@1' has been converted to an output named 'Publish Artifact: Nuget packages' in the templateContext section.
7 | trigger: none
8 | schedules:
9 | - cron: "0 0 14 * *"
10 | branches:
11 | include:
12 | - main
13 | always: true
14 | resources:
15 | repositories:
16 | - repository: self
17 | type: git
18 | ref: refs/heads/main
19 | - repository: MicroBuildTemplate
20 | type: git
21 | name: 1ESPipelineTemplates/MicroBuildTemplate
22 | ref: refs/tags/release
23 | name: $(Date:yyyyMMdd).$(Rev:r)
24 | variables:
25 | TeamName: Asp.Net
26 | EnableNuGetPackageRestore: true
27 | extends:
28 | template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate
29 | parameters:
30 | sdl:
31 | binskim:
32 | enable: true
33 | codeql:
34 | enable: true
35 | policheck:
36 | enable: true
37 | tsa:
38 | enable: true
39 | sourceAnalysisPool:
40 | name: AzurePipelines-EO
41 | image: 1ESPT-Windows2022
42 | os: windows
43 | customBuildTags:
44 | - ES365AIMigrationTooling
45 | stages:
46 | - stage: stage
47 | jobs:
48 | - job: Phase_1
49 | displayName: Phase 1
50 | timeoutInMinutes: 120
51 | cancelTimeoutInMinutes: 1
52 | pool:
53 | name: VSEngSS-MicroBuild2022-1ES
54 | templateContext:
55 | mb:
56 | signing:
57 | enabled: true
58 | signType: test
59 | zipSources: false
60 | outputs:
61 | - output: pipelineArtifact
62 | displayName: 'Publish Artifact: Nuget packages'
63 | artifactName: Nuget packages
64 | targetPath: $(Build.SourcesDirectory)\.binaries\Packages\Release
65 | sbomEnabled: true
66 | sbomBuildDropPath: $(Build.SourcesDirectory)\.binaries\Packages\Release
67 | sbomBuildComponentPath: $(Build.SourcesDirectory)\.binaries\Packages\Release
68 | sbomPackageName: Microsoft.AspNet.OutputCache
69 | # sbomPackageVersion: $(NugetPackageVersion)
70 | sbomValidate: true
71 | steps:
72 | - checkout: self
73 | clean: true
74 | fetchTags: true
75 | persistCredentials: true
76 | - task: NuGetToolInstaller@0
77 | displayName: Use NuGet 5.4.0
78 | inputs:
79 | versionSpec: 5.4.0
80 | checkLatest: true
81 | - task: NuGetCommand@2
82 | displayName: NuGet custom
83 | inputs:
84 | command: custom
85 | arguments: install MicroBuild.Core -version 0.3.0 -OutputDirectory .\packages -source https://devdiv.pkgs.visualstudio.com/DefaultCollection/_packaging/MicroBuildToolset/nuget/v3/index.json
86 | - task: NuGetCommand@2
87 | displayName: NuGet restore
88 | inputs:
89 | solution: Microsoft.Aspnet.SessionState.sln
90 | - task: MSBuild@1
91 | displayName: Build solution MicrosoftAspNetSessionState.msbuild
92 | inputs:
93 | solution: MicrosoftAspNetSessionState.msbuild
94 | msbuildVersion: 17.0
95 | msbuildArchitecture: x64
96 | configuration: Release
97 | msbuildArguments: /p:GitCommit=$(Build.SourceVersion) /p:GitCommitLink="https://github.com/aspnet/AspNetSessionState/commit/$(Build.SourceVersion)" /p:SignType=real /p:SignAssembly=true /verbosity:normal
98 | clean: true
99 | createLogFile: true
100 | logFileVerbosity: detailed
101 | timeoutInMinutes: 120
102 | - task: CopyFiles@2
103 | displayName: Stage dll's for verification
104 | inputs:
105 | SourceFolder: $(Build.SourcesDirectory)\.binaries\bin\Release
106 | Contents: Microsoft.AspNet.SessionState.*.dll
107 | TargetFolder: $(Build.SourcesDirectory)\.binaries\verify\dlls
108 | CleanTargetFolder: true
109 | OverWrite: true
110 | - task: CopyFiles@2
111 | displayName: Stage nupkg's for verification
112 | inputs:
113 | SourceFolder: $(Build.SourcesDirectory)\.binaries\Packages\Release
114 | Contents: |
115 | Microsoft.AspNet.SessionState.*.nupkg
116 | !*.symbols.nupkg
117 | TargetFolder: $(Build.SourcesDirectory)\.binaries\verify\packages
118 | CleanTargetFolder: true
119 | OverWrite: true
120 | - task: ms-vseng.MicroBuildShipTasks.7c429315-71ba-4cb3-94bb-f829c95f7915.MicroBuildCodesignVerify@1
121 | displayName: Verify Signed Binaries
122 | inputs:
123 | TargetFolder: $(Build.SourcesDirectory)\.binaries\verify\dlls
124 | ExcludeFolders: .git MicroBuild apiscan
125 | - task: ms-vseng.MicroBuildShipTasks.7c429315-71ba-4cb3-94bb-f829c95f7915.MicroBuildCodesignVerify@1
126 | displayName: Verify Signed Packages
127 | inputs:
128 | TargetFolder: $(Build.SourcesDirectory)\.binaries\verify\packages
129 | WhiteListPathForCerts: $(Build.SourcesDirectory)\tools\.verif.whitelist
130 | ExcludeFolders: .git MicroBuild decomp *.xml
131 | # Following article on https://dev.azure.com/devdiv/DevDiv/_wiki/wikis/DevDiv.wiki/25351/APIScan-step-by-step-guide-to-setting-up-a-Pipeline
132 | # No longer need the old format, and following guideline to use (ApiScanClientId)
133 | - task: APIScan@2
134 | displayName: Run APIScan
135 | inputs:
136 | softwareFolder: '$(Build.SourcesDirectory)\.binaries\verify\dlls'
137 | softwareName: 'Microsoft.AspNet.SessionState'
138 | softwareVersionNum: '*'
139 | softwareBuildNum: '$(Build.BuildId)'
140 | symbolsFolder: '$(Build.SourcesDirectory)\.binaries\bin\Release;SRV*http://symweb'
141 | verbosityLevel: 'none'
142 | env:
143 | AzureServicesAuthConnectionString: RunAs=App;AppId=$(ApiScanClientId)
--------------------------------------------------------------------------------
/build.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | setlocal
4 | set EnableNuGetPackageRestore=true
5 |
6 | set MSBUILDEXE=msbuild.exe
7 |
8 | set cfgOption=/p:Configuration=Release
9 | REM set cfgOption=/p:Configuration=Debug
10 | REM set cfgOption=/p:Configuration=Debug;Release
11 | if not "%1"=="" set cfgOption=/p:Configuration=
12 |
13 | set logOptions=/v:n /flp:Summary;Verbosity=diag;LogFile=msbuild.log /flp1:warningsonly;logfile=msbuild.wrn /flp2:errorsonly;logfile=msbuild.err
14 |
15 | echo Please build from VS 2015(or newer version) Developer Command Prompt
16 |
17 | :BUILD
18 | %MSBUILDEXE% "%~dp0\MicrosoftAspNetSessionState.msbuild" /t:BuildAll %logOptions% /maxcpucount /nodeReuse:false /p:SkipAdvancedTests=True %cfgOption%%*
19 |
20 | endlocal
21 |
--------------------------------------------------------------------------------
/clean.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | setlocal
4 |
5 | set MSBUILDEXE=msbuild.exe
6 |
7 | set cfgOption=/p:Configuration=Release
8 | REM set cfgOption=/p:Configuration=Debug
9 | REM set cfgOption=/p:Configuration=Debug;Release
10 | if not "%1"=="" set cfgOption=/p:Configuration=
11 |
12 | set logOptions=/v:n /flp:Summary;Verbosity=diag;LogFile=msbuild.log /flp1:warningsonly;logfile=msbuild.wrn /flp2:errorsonly;logfile=msbuild.err
13 |
14 | echo Please build from VS 2015(or newer version) Developer Command Prompt
15 |
16 | :BUILD
17 | %MSBUILDEXE% "%~dp0\MicrosoftAspNetSessionState.msbuild" /t:Clean %logOptions% /maxcpucount /nodeReuse:false %cfgOption%%*
18 | del /F msbuild.*
19 | del /F msbuild.wrn
20 | del /F msbuild.err
21 |
22 | endlocal
23 |
--------------------------------------------------------------------------------
/docs/CosmosDBSessionStateProviderAsync.md:
--------------------------------------------------------------------------------
1 | # Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync
2 | In .Net 4.6.2, asp.net enables developer plug in async version of SessionState module which is a good fit for the non-in-memory SessionState data store. This SessionState provider uses SQL Server as the data store and leverages async database operation to provide better scability.
3 |
4 | Before you can specify this new async providers, you need to setup the new async SessionStateModule as [described here](https://github.com/aspnet/AspNetSessionState/blob/main/docs/SessionStateModule.md).
5 |
6 | Then, register your new provider like so:
7 | ```xml
8 |
9 |
10 |
14 |
15 |
16 | ```
17 | > **Note**
18 | > For the best scalability, it is recommended to configure your CosmosDB provider with "wildcard" partitioning. For update-compatibility purposes, this is not the default. Please read about *partitionKeyPath* and *partitionNumUsedByProvider* below.
19 |
20 | ## Settings for Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync
21 | 1. *cosmosDBEndPointSettingKey* - The appsetting key name which points to a CosmosDB end point
22 |
23 | 2. *cosmosDBAuthKeySettingKey* - The appsetting key name which points to a CosmosDB auth key
24 |
25 | 3. *offerThroughput* - The offer throughput provisioned for a collection in measurement of Requests-per-Unit in the Azure DocumentDB database service. If the collection provided doesn't exist, the provider will create a collection with this offerThroughput. If set to "0", collection will be set to use the default throughput of the database.
26 |
27 | 4. *connectionMode* - Direct | Gateway
28 |
29 | 5. *requestTimeout* - The request timeout in seconds when connecting to the Azure DocumentDB database service.
30 |
31 | 6. *skipKeepAliveWhenUnused* - This setting will skip the call to update expiration time on requests that did not read or write session state. The default is "false" to maintain compatibility with previous behavior. But certain applications (like MVC) where there can be an abundance of requests processed that never even look at session state could benefit from setting this to "true" to reduce the use of and contention within the session state store. Setting this to "true" does mean that a session needs to be used (not necessarily updated, but at least requested/queried) to stay alive.
32 |
33 | 7. *maxConnectionLimit* - maximum number of concurrent connections allowed for the target service endpoint in the Azure DocumentDB database service.
34 |
35 | 8. *maxRetryAttemptsOnThrottledRequests* - the maximum number of retries in the case where the request fails because the Azure DocumentDB database service has applied rate limiting on the client.
36 |
37 | 9. *maxRetryWaitTimeInSeconds* - The maximum retry time in seconds for the Azure DocumentDB database service.
38 |
39 | 10. *consistencyLevel* - The [Consistency Level](https://learn.microsoft.com/en-us/azure/cosmos-db/consistency-levels) to use with the CosmosClient. Default is the Cosmos SDK default, which is currently 'Session'.
40 |
41 | 11. *preferredLocations* - Sets the preferred locations(regions) for geo-replicated database accounts in the Azure DocumentDB database service. Use ';' to split multiple locations. e.g. "East US;South Central US;North Europe"
42 |
--------------------------------------------------------------------------------
/docs/SessionStateModule.md:
--------------------------------------------------------------------------------
1 | # Microsoft.AspNet.SessionState.SessionStateModule
2 | SessionStateModule is ASP.NET’s 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 doesn’t 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](https://blogs.msdn.microsoft.com/webdev/2016/09/29/introducing-the-asp-net-async-sessionstate-module/).
3 |
4 | Before you can specify one of these custom providers. You need to remove the existing session state module from your web.config file. In addition, you must register the new module to take its place.
5 |
6 | ```xml
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | ```
15 |
16 | ## Settings of Microsoft.AspNet.SessionState.SessionStateModule
17 |
18 | 1. appSetting *aspnet:RequestQueueLimitPerSession*
19 |
20 | *How to use* - Add `````` into web.config under appSettings section.
21 |
22 | *Description* - If multiple requests with same sessionid try to acquire sessionstate concurrently, asp.net only allows one request to get the sessionstate. This causes performance issues if there are too many requests with same sessionid and a request doesn't release sessionstate fast enough, as asp.net starts a timer for each of this request to acquire sessionstate every 0.5 sec by default. This is even worse, if out-proc sessionstate provider is used. Because this can potentially use most of the out-proc storage connection resources. With this setting, asp.net will ends the request after the number of concurrent requests with same sessionid reaches the configured number.
23 |
24 | 2. appSetting *aspnet:AllowConcurrentRequestsPerSession*
25 |
26 | *How to use* - Add `````` into web.config under appSettings section.
27 |
28 | *Description* - If multiple requests with same sessionid try to acquire sessionstate concurrently, asp.net only allows one request to get the sessionstate. With this setting, asp.net will allow multiple requests with same sessionid to acquire the sessionstate, but it doesn't guarantee thread safe of accessing sessionstate.
29 |
--------------------------------------------------------------------------------
/docs/SqlSessionStateProviderAsync.md:
--------------------------------------------------------------------------------
1 | # Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync
2 | In .Net 4.6.2, asp.net enables developer plug in async version of SessionState module which is a good fit for the non-in-memory SessionState data store. This SessionState provider uses SQL Server as the data store and leverages async database operation to provide better scability.
3 |
4 | Before you can specify this new async providers, you need to setup the new async SessionStateModule as [described here](https://github.com/aspnet/AspNetSessionState/blob/main/docs/SessionStateModule.md).
5 |
6 | Then, register your new provider like so:
7 | ```xml
8 |
9 |
10 |
14 |
15 |
16 | ```
17 |
18 | ## A Note About Tables and Data Durability
19 | The old in-box SQL provider allowed for applications to choose between three data configurations by using the `-sstype` argument to `aspnet_regsql.exe`. Those types were *p*ermanent, *t*emporary, or *c*ustom. The difference between all three is simply the database and table name used by `aspnet_regsql.exe` and the application at runtime.
20 | * With the permanent option, session state would be stored in a hard-coded well-known table name in the database specified by the connection string. The table schema and data are "permanent" in this setup because they survive SQL server reboot.
21 | * With the temporary option, session state would be stored in a hard-coded well-known table name in the "tempdb" database on the SQL Server specified in the connection string. The "tempdb" database gets cleared upon SQL server reboot, so the data is not kept. The table schema and stored procedures are also cleared in this scenario, but there is a startup procedure that gets registered to re-create session state tables and stored procedures.
22 | * With the custom option, session state would be stored in a table name given by the developer/administrator. The stored procedures created in the database work against that custom table name.
23 |
24 | With this new provider, `aspnet_regsql.exe` is no longer required. (Although, compatibility with stores created by 'aspnet_regsql.exe' can be found when using 'repositoryType=FrameworkCompat'.) When using a `SqlServer` 'repositoryType' the provider will automatically create tables and stored procedures if they don't already exist. By default, that table name is "hard-coded and well-known" - though it has changed from previous versions to avoid inadvertent compatibility problems. You can change that table name by using the 'sessionTableName' attribute on the provider. Whether or not data is 'temporary' or 'permanent' in this type of repository depends entirely on the connection string used. If the connection string indicates using "tempdb", then the data will be temporary. If it indicates a non-temporary initial database, then the data will survive SQL reboots.
25 |
26 | When using a Memory-Optimized 'repositoryType' however, data durability is determined by the optimized table schema. Thus, the provider needs to know what settings to apply to any table it creates. If you want permanent data that survives SQL Server reboots, you must use `InMemoryDurable`.
27 |
28 | ## Settings for Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync
29 | 1. *repositoryType* - One of four values. The default is 'FrameworkCompat' for compatibility reasons - unless the deprecated 'useInMemoryTable' is also set to true, then the default repository type becomes 'InMemory'.
30 | * `SqlServer` - Use this option to use a regular SQL server configuration for a fresh deployment. This configuration will create a session table and associated stored procedures if they don't already exist. (*Note* - the session table expected/created in by this repository type uses a different data type for storing state, and is thus incompatible with the 1.1 release of this provider.)
31 | * `InMemory` - Use this option to leverage "[In-Memory Optimized Tables](https://learn.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/introduction-to-memory-optimized-tables?view=sql-server-ver16)" with "[Natively Compiled Stored Procedures](https://learn.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/a-guide-to-query-processing-for-memory-optimized-tables?view=sql-server-ver16)". New in version 2.0, we create natively compiled stored procedures to go along with the memory-optimized table for an additional performance boost. (V1.1 did not use stored procedures at all.) Tables are durable, but the data is not (`SCHEMA_ONLY`) and will be lost on SQL Server restarts.
32 | * `InMemoryDurable` - The same as above, except with a `SCHEMA_AND_DATA` durable table so session data survives a SQL Server restart.
33 | * `FrameworkCompat` - This mode was introduced to use existing session state databases that were provisioned by `aspnet_regsql.exe`. As such, it does not create any new tables or stored procedures. It does leverage the same stored procedures that are used by the in-box SQL Session State provider.
34 |
35 | This compat configuration ***also*** handles going against a database that was previously configured by V1.1 of these providers, since the current table schema is not fully compatible with the 1.1 table schema. When working against a 1.1-deployed session table, this repository continues to use raw SQL statements instead of stored procedures just like the V1.1 provider did.
36 |
37 | The provider automatically decides between Framework and V1.1 compat modes in this configuration.
38 |
39 | 2. *sessionTableName* - The provider now allows the flexibility to use a particular table name for storing session instead of always using the hard-coded default.
40 |
41 | 3. *maxRetryNumber* - The maximum number of retrying executing sql query to read/write sessionstate data from/to Sql server. The default value is 10.
42 |
43 | 4. *retryInterval* - The interval between the retry of executing sql query. The default value is 0.001 sec for in-memorytable mode. Otherwise the default value is 1 sec.
44 |
45 | 5. *skipKeepAliveWhenUnused* - This setting will skip the call to update expiration time on requests that did not read or write session state. The default is "false" to maintain compatibility with previous behavior. But certain applications (like MVC) where there can be an abundance of requests processed that never even look at session state could benefit from setting this to "true" to reduce the use of and contention within the session state store. Setting this to "true" does mean that a session needs to be used (not necessarily updated, but at least requested/queried) to stay alive.
46 |
47 | 6. **[Deprecated]** *useInMemoryTable* - In the absence of a value for `repositoryType`, this setting will be used to determine whether to use Sql server 2016 In-Memory OLTP for sessionstate. However, if `repositoryType` is specified, that setting takes priority. You can find more details about using In-memory table for sessionstate [on this blog](https://blogs.msdn.microsoft.com/sqlcat/2016/10/26/how-bwin-is-using-sql-server-2016-in-memory-oltp-to-achieve-unprecedented-performance-and-scale/).
48 |
--------------------------------------------------------------------------------
/src/CosmosDBSessionStateProviderAsync/Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {4CFB2896-D5C1-4E96-A3DA-D57C58539209}
9 | Library
10 | Properties
11 | Microsoft.AspNet.SessionStateCosmosDBSessionStateProviderAsync
12 | Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync
13 | v4.6.2
14 | 512
15 |
16 | $(OutputPath)$(AssemblyName).xml
17 | ..\..\
18 |
19 |
20 |
21 |
22 | true
23 | full
24 | false
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 | ..\obj\
29 |
30 |
31 | portable
32 | true
33 | TRACE
34 | prompt
35 | 4
36 | ..\obj\
37 |
38 |
39 | true
40 |
41 |
42 | $(RepositoryRoot)tools\35MSSharedLib1024.snk
43 |
44 |
45 | true
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | True
74 | True
75 | SR.resx
76 |
77 |
78 |
79 |
80 |
81 | {7238f90d-3bce-4f40-a5ba-ea36ad484bd6}
82 | Microsoft.AspNet.SessionState.SessionStateModule
83 |
84 |
85 |
86 |
87 | ResXFileCodeGenerator
88 | SR.Designer.cs
89 |
90 |
91 |
92 |
93 | 3.46.1
94 |
95 |
110 |
111 | 13.0.1
112 |
113 |
114 | 8.0.5
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/src/CosmosDBSessionStateProviderAsync/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See the License.txt file in the project root for full license information.
3 |
4 | using System.Reflection;
5 | using System.Runtime.CompilerServices;
6 | using System.Runtime.InteropServices;
7 |
8 | // General Information about an assembly is controlled through the following
9 | // set of attributes. Change these attribute values to modify the information
10 | // associated with an assembly.
11 | [assembly: AssemblyTitle("Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync")]
12 | [assembly: AssemblyDescription("Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.dll")]
13 | [assembly: AssemblyConfiguration("")]
14 | [assembly: AssemblyCompany("Microsoft Corporation")]
15 | [assembly: AssemblyProduct("Microsoft AspNet Async CosmosDBSessionStateProvider")]
16 | [assembly: AssemblyCopyright("\x00a9 Microsoft Corporation. All rights reserved.")]
17 | [assembly: AssemblyTrademark("")]
18 | [assembly: AssemblyCulture("")]
19 |
20 | // Setting ComVisible to false makes the types in this assembly not visible
21 | // to COM components. If you need to access a type in this assembly from
22 | // COM, set the ComVisible attribute to true on that type.
23 | [assembly: ComVisible(false)]
24 |
25 | // The following GUID is for the ID of the typelib if this project is exposed to COM
26 | [assembly: Guid("4cfb2896-d5c1-4e96-a3da-d57c58539209")]
27 | [assembly: InternalsVisibleTo("Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
28 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
29 |
--------------------------------------------------------------------------------
/src/CosmosDBSessionStateProviderAsync/Resources/SR.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Microsoft.AspNet.SessionState.Resources {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class SR {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal SR() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.SessionStateCosmosDBSessionStateProviderAsync.Resources.SR", typeof(SR).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized string similar to Parameter '{0}' cannot be null..
65 | ///
66 | internal static string ArgumentNull_WithParamName {
67 | get {
68 | return ResourceManager.GetString("ArgumentNull_WithParamName", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Looks up a localized string similar to The specified container '{0}' already exists with a partition key path other than '{1}'..
74 | ///
75 | internal static string Container_PKey_Does_Not_Match {
76 | get {
77 | return ResourceManager.GetString("Container_PKey_Does_Not_Match", resourceCulture);
78 | }
79 | }
80 |
81 | ///
82 | /// Looks up a localized string similar to Configuration '{0}' cannot be null..
83 | ///
84 | internal static string EmptyConfig_WithName {
85 | get {
86 | return ResourceManager.GetString("EmptyConfig_WithName", resourceCulture);
87 | }
88 | }
89 |
90 | ///
91 | /// Looks up a localized string similar to The session state information is invalid and might be corrupted..
92 | ///
93 | internal static string Invalid_session_state {
94 | get {
95 | return ResourceManager.GetString("Invalid_session_state", resourceCulture);
96 | }
97 | }
98 |
99 | ///
100 | /// Looks up a localized string similar to The request rate to CosmosDB is too large. You may consider to increase the offer throughput of the CosmosDB collection or increase maxRetryAttemptsOnThrottledRequests and maxRetryWaitTimeInSeconds settings in web.config.
101 | ///
102 | internal static string Request_To_CosmosDB_Is_Too_Large {
103 | get {
104 | return ResourceManager.GetString("Request_To_CosmosDB_Is_Too_Large", resourceCulture);
105 | }
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/src/CosmosDBSessionStateProviderAsync/Resources/SR.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Parameter '{0}' cannot be null.
122 |
123 |
124 | The specified container '{0}' already exists with a partition key path other than '{1}'.
125 |
126 |
127 | Configuration '{0}' cannot be null.
128 |
129 |
130 | The session state information is invalid and might be corrupted.
131 |
132 |
133 | The request rate to CosmosDB is too large. You may consider to increase the offer throughput of the CosmosDB collection or increase maxRetryAttemptsOnThrottledRequests and maxRetryWaitTimeInSeconds settings in web.config
134 |
135 |
--------------------------------------------------------------------------------
/src/CosmosDBSessionStateProviderAsync/SessionStateActionsConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See the License.txt file in the project root for full license information.
3 |
4 | namespace Microsoft.AspNet.SessionState {
5 | using System;
6 | using System.Web.SessionState;
7 | using System.Text.Json;
8 | using System.Text.Json.Serialization;
9 |
10 | class SessionStateActionsConverter : JsonConverter
11 | {
12 | public override bool CanConvert(Type typeToConvert)
13 | {
14 | return typeof(SessionStateActions?) == typeToConvert;
15 | }
16 |
17 | public override SessionStateActions? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
18 | {
19 | if (reader.TokenType == JsonTokenType.Null)
20 | {
21 | return new Nullable();
22 | }
23 |
24 | if (reader.TokenType != JsonTokenType.True && reader.TokenType != JsonTokenType.False)
25 | {
26 | throw new ArgumentException("reader");
27 | }
28 |
29 | // See the note below in the writer for how to map this flags enum from a boolean.
30 | return reader.GetBoolean() ? SessionStateActions.InitializeItem : SessionStateActions.None;
31 | }
32 |
33 | public override void Write(Utf8JsonWriter writer, SessionStateActions? action, JsonSerializerOptions options)
34 | {
35 | if (action == null)
36 | {
37 | writer.WriteNullValue();
38 | return;
39 | }
40 |
41 | // SessionStateActions is a [Flags] enum. The SQL providers serialize it as flags. I don't know why we didn't
42 | // just go with int or something flag-like here instead of true/false.
43 | // 'None' means that the initialization of this state item has already been done and
44 | // thus the item is considered initialized. We serialize this item with the field name
45 | // "uninitialized", so 'None' should map to false.
46 | writer.WriteBooleanValue((action != SessionStateActions.None));
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/CosmosDBSessionStateProviderAsync/SessionStateItem.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See the License.txt file in the project root for full license information.
3 |
4 | namespace Microsoft.AspNet.SessionState
5 | {
6 | using System;
7 | using System.Web.SessionState;
8 | using System.Text.Json.Serialization;
9 |
10 | class SessionStateItem
11 | {
12 | [JsonPropertyName("id")]
13 | [JsonRequired]
14 | public string SessionId { get; set; }
15 |
16 | // in second
17 | [JsonPropertyName("lockAge")]
18 | [JsonConverter(typeof(TimeSpanConverter))]
19 | public TimeSpan? LockAge { get; set; }
20 |
21 | [JsonPropertyName("lockCookie")]
22 | public int? LockCookie { get; set; }
23 |
24 | //in sec
25 | // Leverage CosmosDB's TTL function to remove expired sessionstate item
26 | //ref https://docs.microsoft.com/en-us/azure/cosmos-db/time-to-live
27 | [JsonPropertyName("ttl")]
28 | public int? Timeout { get; set; }
29 |
30 | [JsonPropertyName("locked")]
31 | public bool? Locked { get; set; }
32 |
33 | [JsonPropertyName("sessionItem")]
34 | public byte[] SessionItem { get; set; }
35 |
36 | [JsonPropertyName("uninitialized")]
37 | [JsonConverter(typeof(SessionStateActionsConverter))]
38 | public SessionStateActions? Actions {get;set;}
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/CosmosDBSessionStateProviderAsync/SystemTextJsonSerializer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See the License.txt file in the project root for full license information.
3 |
4 | namespace Microsoft.AspNet.SessionState
5 | {
6 | using Microsoft.Azure.Cosmos;
7 | using System.IO;
8 | using System.Text.Json;
9 |
10 | internal class SystemTextJsonSerializer : CosmosSerializer
11 | {
12 | private JsonSerializerOptions _opts;
13 |
14 | public SystemTextJsonSerializer(JsonSerializerOptions jsonSerializerOptions)
15 | {
16 | _opts = jsonSerializerOptions ?? default(JsonSerializerOptions);
17 | }
18 |
19 | public override T FromStream(Stream stream)
20 | {
21 | using (stream)
22 | {
23 | if (stream.CanSeek
24 | && stream.Length == 0)
25 | {
26 | return default;
27 | }
28 |
29 | if (typeof(Stream).IsAssignableFrom(typeof(T)))
30 | {
31 | return (T)(object)stream;
32 | }
33 |
34 | return JsonSerializer.Deserialize(stream, _opts);
35 | }
36 | }
37 |
38 | public override Stream ToStream(T input)
39 | {
40 | MemoryStream ms = new MemoryStream();
41 | JsonSerializer.Serialize(ms, input, input.GetType(), _opts);
42 | ms.Position = 0;
43 | return ms;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/CosmosDBSessionStateProviderAsync/TimeSpanConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See the License.txt file in the project root for full license information.
3 |
4 | namespace Microsoft.AspNet.SessionState
5 | {
6 | using System;
7 | using System.Text.Json;
8 | using System.Text.Json.Serialization;
9 | using Microsoft.AspNet.SessionState.Resources;
10 |
11 | class TimeSpanConverter : JsonConverter
12 | {
13 | public override bool CanConvert(Type typeToConvert)
14 | {
15 | return typeof(TimeSpan?) == typeToConvert;
16 | }
17 |
18 | public override TimeSpan? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
19 | {
20 | if (reader.TokenType == JsonTokenType.Null)
21 | {
22 | return new Nullable();
23 | }
24 |
25 | if (reader.TokenType != JsonTokenType.Number)
26 | {
27 | throw new ArgumentException("reader");
28 | }
29 |
30 | return new TimeSpan(0, 0, reader.GetInt32());
31 | }
32 |
33 | public override void Write(Utf8JsonWriter writer, TimeSpan? value, JsonSerializerOptions options)
34 | {
35 | if (value == null)
36 | {
37 | writer.WriteNullValue();
38 | return;
39 | }
40 |
41 | var ts = (TimeSpan)value;
42 | writer.WriteNumberValue((int)ts.TotalSeconds);
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/SessionStateModule/AppSettings.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See the License.txt file in the project root for full license information.
3 |
4 | namespace Microsoft.AspNet.SessionState
5 | {
6 | using System.Collections.Specialized;
7 | using System.Web.Configuration;
8 |
9 | static class AppSettings
10 | {
11 | private static volatile bool _settingsInitialized;
12 | private static object _lock = new object();
13 |
14 | private static void LoadSettings(NameValueCollection appSettings)
15 | {
16 | //
17 | // RequestQueueLimitPerSession
18 | //
19 | string requestQueueLimit = appSettings["aspnet:RequestQueueLimitPerSession"];
20 |
21 | if (!int.TryParse(requestQueueLimit, out _requestQueueLimitPerSession) || _requestQueueLimitPerSession < 0)
22 | {
23 | _requestQueueLimitPerSession = DefaultRequestQueueLimitPerSession;
24 | }
25 |
26 | //
27 | // AllowConcurrentRequests
28 | //
29 | string allowConcurrentRequestPerSession = appSettings["aspnet:AllowConcurrentRequestsPerSession"];
30 | bool.TryParse(allowConcurrentRequestPerSession, out _allowConcurrentRequestsPerSession);
31 | }
32 |
33 | private static void EnsureSettingsLoaded()
34 | {
35 | if (_settingsInitialized)
36 | {
37 | return;
38 | }
39 |
40 | lock (_lock)
41 | {
42 | if (!_settingsInitialized)
43 | {
44 | try
45 | {
46 | LoadSettings(WebConfigurationManager.AppSettings);
47 | }
48 | finally
49 | {
50 | _settingsInitialized = true;
51 | }
52 | }
53 | }
54 | }
55 |
56 | //
57 | // RequestQueueLimitPerSession
58 | // Limit of queued requests per session
59 | //
60 | public const int DefaultRequestQueueLimitPerSession = 50;
61 | private static int _requestQueueLimitPerSession = DefaultRequestQueueLimitPerSession;
62 |
63 | public static int RequestQueueLimitPerSession
64 | {
65 | get
66 | {
67 | EnsureSettingsLoaded();
68 | return _requestQueueLimitPerSession;
69 | }
70 | }
71 |
72 | private static bool _allowConcurrentRequestsPerSession = false;
73 | public static bool AllowConcurrentRequestsPerSession
74 | {
75 | get
76 | {
77 | EnsureSettingsLoaded();
78 | return _allowConcurrentRequestsPerSession;
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/SessionStateModule/Microsoft.AspNet.SessionState.SessionStateModule.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {7238F90D-3BCE-4F40-A5BA-EA36AD484BD6}
9 | Library
10 | Properties
11 | Microsoft.AspNet.SessionState
12 | Microsoft.AspNet.SessionState.SessionStateModule
13 | v4.6.2
14 | 512
15 |
16 | $(OutputPath)$(AssemblyName).xml
17 | ..\..\
18 |
19 |
20 | true
21 | full
22 | false
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 | ..\obj\
27 |
28 |
29 | portable
30 | true
31 | TRACE
32 | prompt
33 | 4
34 | ..\obj\
35 |
36 |
37 | true
38 |
39 |
40 | $(RepositoryRoot)tools\35MSSharedLib1024.snk
41 |
42 |
43 | true
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | True
64 | True
65 | SR.resx
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | ResXFileCodeGenerator
78 | SR.Designer.cs
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/src/SessionStateModule/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See the License.txt file in the project root for full license information.
3 |
4 | using System.Reflection;
5 | using System.Runtime.CompilerServices;
6 | using System.Runtime.InteropServices;
7 |
8 | // General Information about an assembly is controlled through the following
9 | // set of attributes. Change these attribute values to modify the information
10 | // associated with an assembly.
11 | [assembly: AssemblyTitle("Microsoft.AspNet.SessionState.SessionStateModule.dll")]
12 | [assembly: AssemblyDescription("Microsoft.AspNet.SessionState.SessionStateModule.dll")]
13 | [assembly: AssemblyConfiguration("")]
14 | [assembly: AssemblyCompany("Microsoft Corporation")]
15 | [assembly: AssemblyProduct("Microsoft AspNet SessionStateModule")]
16 | [assembly: AssemblyCopyright("\x00a9 Microsoft Corporation. All rights reserved.")]
17 | [assembly: AssemblyTrademark("")]
18 | [assembly: AssemblyCulture("")]
19 |
20 | // Setting ComVisible to false makes the types in this assembly not visible
21 | // to COM components. If you need to access a type in this assembly from
22 | // COM, set the ComVisible attribute to true on that type.
23 | [assembly: ComVisible(false)]
24 |
25 | // The following GUID is for the ID of the typelib if this project is exposed to COM
26 | [assembly: Guid("7238f90d-3bce-4f40-a5ba-ea36ad484bd6")]
27 |
--------------------------------------------------------------------------------
/src/SessionStateModule/Resources/SR.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Microsoft.AspNet.SessionState.Resources {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class SR {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal SR() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.SessionState.Resources.SR", typeof(SR).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized string similar to Unable to serialize the session state. For out-of-proc session stores, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted..
65 | ///
66 | internal static string Cant_serialize_session_state {
67 | get {
68 | return ResourceManager.GetString("Cant_serialize_session_state", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Looks up a localized string similar to Error occured when reading config secion '{0}'..
74 | ///
75 | internal static string Error_Occured_Reading_Config_Secion {
76 | get {
77 | return ResourceManager.GetString("Error_Occured_Reading_Config_Secion", resourceCulture);
78 | }
79 | }
80 |
81 | ///
82 | /// Looks up a localized string similar to The value for the '{0}' option on provider name '{1}' is invalid..
83 | ///
84 | internal static string Invalid_provider_option {
85 | get {
86 | return ResourceManager.GetString("Invalid_provider_option", resourceCulture);
87 | }
88 | }
89 |
90 | ///
91 | /// Looks up a localized string similar to The custom session state store provider name '{0}' is invalid..
92 | ///
93 | internal static string Invalid_session_custom_provider {
94 | get {
95 | return ResourceManager.GetString("Invalid_session_custom_provider", resourceCulture);
96 | }
97 | }
98 |
99 | ///
100 | /// Looks up a localized string similar to The session state information is invalid and might be corrupted..
101 | ///
102 | internal static string Invalid_session_state {
103 | get {
104 | return ResourceManager.GetString("Invalid_session_state", resourceCulture);
105 | }
106 | }
107 |
108 | ///
109 | /// Looks up a localized string similar to The custom session state store provider '{0}' is not found..
110 | ///
111 | internal static string Missing_session_custom_provider {
112 | get {
113 | return ResourceManager.GetString("Missing_session_custom_provider", resourceCulture);
114 | }
115 | }
116 |
117 | ///
118 | /// Looks up a localized string similar to SessionStateAsync module only supports InProc and Custom mode..
119 | ///
120 | internal static string Not_Support_SessionState_Mode {
121 | get {
122 | return ResourceManager.GetString("Not_Support_SessionState_Mode", resourceCulture);
123 | }
124 | }
125 |
126 | ///
127 | /// Looks up a localized string similar to The SessionStateStoreData returned by ISessionStateStore has a null value for Items..
128 | ///
129 | internal static string Null_value_for_SessionStateItemCollection {
130 | get {
131 | return ResourceManager.GetString("Null_value_for_SessionStateItemCollection", resourceCulture);
132 | }
133 | }
134 |
135 | ///
136 | /// Looks up a localized string similar to The request queue limit of the session is exceeded..
137 | ///
138 | internal static string Request_Queue_Limit_Per_Session_Exceeded {
139 | get {
140 | return ResourceManager.GetString("Request_Queue_Limit_Per_Session_Exceeded", resourceCulture);
141 | }
142 | }
143 |
144 | ///
145 | /// Looks up a localized string similar to SessionId is too long..
146 | ///
147 | internal static string Session_id_too_long {
148 | get {
149 | return ResourceManager.GetString("Session_id_too_long", resourceCulture);
150 | }
151 | }
152 |
153 | ///
154 | /// Looks up a localized string similar to Type '{0}' does not inherit from '{1}'..
155 | ///
156 | internal static string Type_doesnt_inherit_from_type {
157 | get {
158 | return ResourceManager.GetString("Type_doesnt_inherit_from_type", resourceCulture);
159 | }
160 | }
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/src/SessionStateModule/Resources/SR.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Unable to serialize the session state. For out-of-proc session stores, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted.
122 |
123 |
124 | Error occured when reading config secion '{0}'.
125 |
126 |
127 | The value for the '{0}' option on provider name '{1}' is invalid.
128 |
129 |
130 | The custom session state store provider name '{0}' is invalid.
131 |
132 |
133 | The session state information is invalid and might be corrupted.
134 |
135 |
136 | The custom session state store provider '{0}' is not found.
137 |
138 |
139 | SessionStateAsync module only supports InProc and Custom mode.
140 |
141 |
142 | The SessionStateStoreData returned by ISessionStateStore has a null value for Items.
143 |
144 |
145 | The request queue limit of the session is exceeded.
146 |
147 |
148 | SessionId is too long.
149 |
150 |
151 | Type '{0}' does not inherit from '{1}'.
152 |
153 |
--------------------------------------------------------------------------------
/src/SessionStateModule/SessionEventSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See the License.txt file in the project root for full license information.
3 |
4 | namespace Microsoft.AspNet.SessionState
5 | {
6 | using System;
7 | using System.Diagnostics.Tracing;
8 | using System.Web;
9 |
10 | [EventSource(Guid = "e195a708-06d5-4605-bbfe-818c9ff8e124",
11 | Name = "Microsoft-AspNet-SessionState-SessionStateModule")]
12 | class SessionEventSource : EventSource
13 | {
14 | private SessionEventSource()
15 | {
16 | }
17 |
18 | public static SessionEventSource Log { get; } = new SessionEventSource();
19 |
20 | [NonEvent]
21 | public void SessionDataBegin(HttpContext context)
22 | {
23 | if (IsEnabled() && context != null)
24 | {
25 | RaiseEvent(SessionDataBegin, context);
26 | }
27 | }
28 |
29 | [Event(42, Level = EventLevel.Informational, Keywords = Keywords.AspNetReq)]
30 | private void SessionDataBegin(Guid contextId)
31 | {
32 | WriteEvent(EventType.SessionDataBegin, contextId);
33 | }
34 |
35 | [NonEvent]
36 | public void SessionDataEnd(HttpContext context)
37 | {
38 | if (IsEnabled())
39 | {
40 | RaiseEvent(SessionDataEnd, context);
41 | }
42 | }
43 |
44 |
45 | [Event(43, Level = EventLevel.Informational, Keywords = Keywords.AspNetReq)]
46 | private void SessionDataEnd(Guid contextId)
47 | {
48 | if (IsEnabled())
49 | {
50 | WriteEvent(EventType.SessionDataEnd, contextId);
51 | }
52 | }
53 |
54 | [NonEvent]
55 | private void RaiseEvent(Action action, HttpContext context)
56 | {
57 | HttpWorkerRequest workerRequest = GetWorkerRequest(context);
58 | if (workerRequest == null)
59 | return;
60 |
61 | action(workerRequest.RequestTraceIdentifier);
62 | }
63 |
64 | [NonEvent]
65 | private HttpWorkerRequest GetWorkerRequest(HttpContext context)
66 | {
67 | IServiceProvider serviceProvider = context;
68 | var workerRequest = (HttpWorkerRequest) serviceProvider.GetService(typeof (HttpWorkerRequest));
69 |
70 | return workerRequest;
71 | }
72 |
73 | class EventType
74 | {
75 | public static readonly int SessionDataBegin = 42;
76 | public static readonly int SessionDataEnd = 43;
77 | }
78 |
79 | public class Keywords
80 | {
81 | public const EventKeywords AspNetReq = (EventKeywords) 1;
82 | }
83 | }
84 | }
--------------------------------------------------------------------------------
/src/SessionStateModule/SessionOnEndTarget.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See the License.txt file in the project root for full license information.
3 |
4 | namespace Microsoft.AspNet.SessionState
5 | {
6 | using System;
7 | using System.Web.SessionState;
8 |
9 | /*
10 | * Calls the OnSessionEnd event. We use an object other than the SessionStateModule
11 | * because the state of the module is unknown - it could have been disposed
12 | * when a session ends.
13 | */
14 |
15 | class SessionOnEndTarget
16 | {
17 | private int _sessionEndEventHandlerCount;
18 |
19 | public int SessionEndEventHandlerCount
20 | {
21 | get { return _sessionEndEventHandlerCount; }
22 | set { _sessionEndEventHandlerCount = value; }
23 | }
24 |
25 | public void RaiseOnEnd(HttpSessionStateContainer sessionStateContainer)
26 | {
27 | if (_sessionEndEventHandlerCount > 0)
28 | {
29 | SessionStateUtility.RaiseSessionEnd(sessionStateContainer, this, EventArgs.Empty);
30 | }
31 | }
32 |
33 | public void RaiseSessionOnEnd(string id, SessionStateStoreData item)
34 | {
35 | var sessionStateContainer = new HttpSessionStateContainer(
36 | id,
37 | item.Items,
38 | item.StaticObjects,
39 | item.Timeout,
40 | false,
41 | SessionStateModuleAsync.ConfigCookieless,
42 | SessionStateModuleAsync.ConfigMode,
43 | true);
44 |
45 | RaiseOnEnd(sessionStateContainer);
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/src/SessionStateModule/TaskAsyncHelper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT license. See the License.txt file in the project root for full license information.
3 |
4 | namespace Microsoft.AspNet.SessionState
5 | {
6 | using System;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 | using System.Web;
10 |
11 | static class TaskAsyncHelper
12 | {
13 | private static readonly Task CompletedTask = Task.FromResult