Skip to content

Commit 1f25cd8

Browse files
JinhuafeiHongGit
authored andcommitted
Changes for OSS (#4)
* added SqlSessionStateAsyncProviderTest * added unit tests for cosmosdb provider * update build * update readme * update license info
1 parent 100cd77 commit 1f25cd8

32 files changed

+2588
-145
lines changed

License.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
2+
Microsoft Open Technologies would like to thank its contributors, a list of whom
3+
are at http://aspnetwebstack.codeplex.com/wikipage?title=Contributors.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License"); you
6+
may not use this file except in compliance with the License. You may
7+
obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14+
implied. See the License for the specific language governing permissions
15+
and limitations under the License.

Microsoft.Aspnet.SessionState.sln

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26430.16
4+
VisualStudioVersion = 15.0.27130.2036
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{58E8143E-86D8-4CA3-AAC3-1CF253D91207}"
77
EndProject
@@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.SessionSta
1515
EndProject
1616
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}"
1717
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
1820
Global
1921
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2022
Debug|Any CPU = Debug|Any CPU
@@ -36,6 +38,10 @@ Global
3638
{CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
3739
{CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
3840
{CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2}.Release|Any CPU.Build.0 = Release|Any CPU
41+
{2AF89ACA-3545-432D-8D99-C5230E8643A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42+
{2AF89ACA-3545-432D-8D99-C5230E8643A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
43+
{2AF89ACA-3545-432D-8D99-C5230E8643A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
44+
{2AF89ACA-3545-432D-8D99-C5230E8643A8}.Release|Any CPU.Build.0 = Release|Any CPU
3945
EndGlobalSection
4046
GlobalSection(SolutionProperties) = preSolution
4147
HideSolutionNode = FALSE
@@ -45,5 +51,9 @@ Global
4551
{4CFB2896-D5C1-4E96-A3DA-D57C58539209} = {58E8143E-86D8-4CA3-AAC3-1CF253D91207}
4652
{7238F90D-3BCE-4F40-A5BA-EA36AD484BD6} = {58E8143E-86D8-4CA3-AAC3-1CF253D91207}
4753
{CBB00B6C-8A44-43F0-BE73-0B0E8565F8A2} = {93AD624B-85A6-4EE9-B40E-42914D40C0CF}
54+
{2AF89ACA-3545-432D-8D99-C5230E8643A8} = {93AD624B-85A6-4EE9-B40E-42914D40C0CF}
55+
EndGlobalSection
56+
GlobalSection(ExtensibilityGlobals) = postSolution
57+
SolutionGuid = {4853AD21-0DCE-40D8-A3B9-19081B71C364}
4858
EndGlobalSection
4959
EndGlobal

MicrosoftAspNetSessionState.msbuild

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
<AssemblyProject Include="src\SqlSessionStateProviderAsync\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.csproj" />
77
<AssemblyProject Include="src\CosmosDBSessionStateProviderAsync\Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.csproj" />
88
</ItemGroup>
9-
<ItemGroup Condition="'$(BuildCoreOnly)' != 'true'">
10-
<AssemblyProject Include="test\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test.csproj" />
9+
<ItemGroup>
10+
<TestProject Include="test\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test\Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test.csproj" />
11+
<TestProject Include="test\Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.Test\Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync.Test.csproj" />
1112
</ItemGroup>
1213
<ItemGroup>
1314
<PackageProject Include="src\Packages\Packages.csproj" />
1415
</ItemGroup>
1516

16-
<Target Name="Build" DependsOnTargets="BuildAssemblies;BuildPackages" />
17+
<Target Name="Build" DependsOnTargets="BuildAssemblies;UnitTest;BuildPackages" />
1718
<Target Name="Clean" DependsOnTargets="CleanPackages;CleanAssemblies" />
1819
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
1920

2021
<Target Name="BuildAssemblies" DependsOnTargets="RestorePackages">
21-
<MSBuild Targets="Build" Projects="@(AssemblyProject)" />
22+
<MSBuild Targets="Build" Projects="@(AssemblyProject);@(TestProject)" />
2223
</Target>
2324

2425
<Target Name="CleanAssemblies">
@@ -43,21 +44,10 @@
4344
<Exec Command=".nuget\NuGet.exe restore" />
4445
</Target>
4546

46-
<!--
47-
<Target Name="UnitTest">
48-
<ItemGroup>
49-
<TestDLLs Include="test\SystemWebProvidersUnitTest\bin\$(Configuration)\*Test.dll" />
50-
</ItemGroup>
51-
52-
<PropertyGroup>
53-
<TestSettingsFile Condition=" '$(Configuration)' == 'CodeCoverage' ">$(MsBuildProjectDirectory)\test\CodeCoverage.testsettings</TestSettingsFile>
54-
<TestSettingsFile Condition=" '$(Configuration)' != 'CodeCoverage' ">$(MsBuildProjectDirectory)\unittest.testsettings</TestSettingsFile>
55-
</PropertyGroup>
56-
57-
<Delete Files="bin\$(Configuration)-TestResults.trx" />
58-
<Exec
59-
Command="&quot;$(VS100COMNTOOLS)..\IDE\MSTEST.EXE&quot; /nologo /usestderr /resultsfile:&quot;bin\$(Configuration)-TestResults.trx&quot; @(TestDLLs -> '/testcontainer:&quot;%(Identity)&quot;', ' ') /testsettings:&quot;$(TestSettingsFile)&quot;" />
60-
</Target>
61-
-->
47+
48+
<Target Name="UnitTest">
49+
<MSBuild Targets="XunitTest" Projects="@(TestProject)" />
50+
</Target>
51+
6252
<Import Project="tools\MicrosoftAspNetSessionState.targets"/>
6353
</Project>

Readme.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
## Settings of the module and providers
10+
11+
+ #### Microsoft.AspNet.SessionState.SessionStateModule
12+
13+
1. appSetting *aspnet:RequestQueueLimitPerSession*
14+
15+
*How to use* - Add ```<add key="aspnet:RequestQueueLimitPerSession" value="[int]"/>``` into web.config under appSettings section.
16+
17+
*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.
18+
19+
2. appSetting *aspnet:AllowConcurrentRequestsPerSession*
20+
21+
*How to use* - Add ```<add key="aspnet:AllowConcurrentRequestsPerSession" value="[int]"/>``` into web.config under appSettings section.
22+
23+
*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.
24+
25+
+ #### Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync
26+
27+
The settings of this provider is located in the following configuration section in web.config.
28+
```
29+
<sessionState cookieless="false" regenerateExpiredSessionId="true" mode="Custom" customProvider="SqlSessionStateProviderAsync">
30+
<providers>
31+
<add name="SqlSessionStateProviderAsync" connectionStringName="DefaultConnection" UseInMemoryTable="[true|false]" MaxRetryNumber="[int]" RetryInterval="[int]"
32+
type="Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync, Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
33+
</providers>
34+
```
35+
36+
1. *UseInMemoryTable* - Indicates whether to use Sql server 2016 In-Memory OLTP for sessionstate. 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/).
37+
38+
2. *MaxRetryNumber* - The maximum number of retrying executing sql query to read/write sessionstate data from/to Sql server. The default value is 10.
39+
40+
3. *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.
41+
42+
+ #### Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync
43+
44+
The settings of this provider is located in the following configuration section in web.config.
45+
```
46+
<sessionState cookieless="false" regenerateExpiredSessionId="true" mode="Custom" customProvider="CosmosDBSessionStateProviderAsync">
47+
<providers>
48+
<add name="CosmosDBSessionStateProviderAsync" cosmosDBEndPointSettingKey="cosmosDBEndPointSetting" cosmosDBAuthKeySettingKey="cosmosDBAuthKeySetting"
49+
databaseId="[DataBaseId]" collectionId="[CollectionId]" offerThroughput="5000" connectionMode="Direct" connectionProtocol="Tcp" requestTimeout="5"
50+
maxConnectionLimit="50" maxRetryAttemptsOnThrottledRequests="10" maxRetryWaitTimeInSeconds="10" preferredLocations="" partitionKey=""
51+
partitionNumUsedByProvider=""
52+
type="Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync, Microsoft.AspNet.SessionState.CosmosDBSessionStateProviderAsync, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
53+
</providers>
54+
</sessionState>
55+
```
56+
1. *cosmosDBEndPointSettingKey* - The appsetting key name which points to a CosmosDB end point
57+
58+
2. *cosmosDBAuthKeySettingKey* - The appsetting key name which points to a CosmosDB auth key
59+
60+
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.
61+
62+
4. *connectionMode* - Direct | Gateway
63+
64+
5. *connectionProtocol* - Https | Tcp
65+
66+
6. *requestTimeout* - The request timeout in seconds when connecting to the Azure DocumentDB database service.
67+
68+
7. *maxConnectionLimit* - maximum number of concurrent connections allowed for the target service endpoint in the Azure DocumentDB database service.
69+
70+
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.
71+
72+
9. *maxRetryWaitTimeInSeconds* - The maximum retry time in seconds for the Azure DocumentDB database service.
73+
74+
10. *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"
75+
76+
11. *partitionKey* - The partition key name of the collection
77+
78+
12. *partitionNumUsedByProvider* - the number of partition can be used for sessionstate

Readme.txt

Whitespace-only changes.

build.cmd

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,12 @@
22

33
setlocal
44

5-
set logOptions=/flp:Summary;Verbosity=diag;LogFile=msbuild.log /flp1:warningsonly;logfile=msbuild.wrn /flp2:errorsonly;logfile=msbuild.err
5+
set logOptions=/flp:Summary;Verbosity=m;LogFile=msbuild.log /flp1:warningsonly;logfile=msbuild.wrn /flp2:errorsonly;logfile=msbuild.err
66

7-
set MSBUILDEXE=
8-
if exist "%SystemDrive%\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" (
9-
set MSBUILDEXE="%SystemDrive%\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"
10-
GOTO BUILD
11-
)
12-
13-
if exist "%SystemDrive%\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" (
14-
set MSBUILDEXE="%SystemDrive%\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe"
15-
GOTO BUILD
16-
)
17-
18-
if not defined MSBUILDEXE (
19-
set MSBUILDEXE="C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
20-
)
7+
echo Please build from VS 2015(or newer version) Developer Command Prompt
218

229
:BUILD
2310
REM %MSBUILDEXE% "%~dp0\MicrosoftAspNetSessionState.msbuild" %logOptions% /v:d /maxcpucount /nodeReuse:false %*
24-
%MSBUILDEXE% "%~dp0\MicrosoftAspNetSessionState.msbuild" %logOptions% /v:diag /maxcpucount /nodeReuse:false %*
11+
msbuild "%~dp0\MicrosoftAspNetSessionState.msbuild" %logOptions% /v:m /maxcpucount /nodeReuse:false %*
2512

2613
endlocal

0 commit comments

Comments
 (0)