顯示具有 Session State 標籤的文章。 顯示所有文章
顯示具有 Session State 標籤的文章。 顯示所有文章

2022年4月12日 星期二

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(三)Microsoft.AspNet.Providers

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(三)Microsoft.AspNet.Providers

2022-04-12

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#

續這篇

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(一)aspnet_regsql.exe
https://shaurong.blogspot.com/2022/04/aspnet-sql-server-session-state.html

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(二)System.Web.Providers
https://shaurong.blogspot.com/2022/04/aspnet-sql-server-session-state_12.html

用aspnet_regsql.exe需要自己手動在SQL Server建立資料表,用 NuGet 安裝 System.Web.Providers可讓系統自動在資料庫建立 dbo.sessions資料表。

先用 NuGet 安裝 System.Web.Providers 1.2.0,其實描述有說 Legacy package, System.Web.Providers is now included in the 'Microsoft.AspNet.Providers' package.,這次不要安裝 System.Web.Providers,直接安裝 Microsoft.AspNet.Providers。

ASP.NET Universal Providers add provider support in ASP.NET 4 for all editions of SQL Server 2005 and later and to SQL Azure. If you use these providers to develop your application, the application will be ready for cloud environments like Azure. Other than supporting additional storage options, the providers work like the existing SQL-based providers, so that you can easily switch an application to use cloud storage via SQL Azure.

它會要求安裝相依套件:

EntityFramework.6.0.0

Microsoft.AspNet.Providers.Core.2.0.0

Microsoft.AspNet.Providers.2.0.0

NuGet會在Web.Config建立一個資料庫連線 DefaultConnection,還有一堆設定使用該連線。

之後隨便建立一個 Default.aspx (隨便取個名稱),拖拉一個SqlDataSource控制項過去,設定資料庫連線,假設稱為 TestDB7ConnectionString。(要先在 TestDB7 中隨便建立一個資料表才能做)

最後把 Web.Config 中 "DefaultConnection" 字串全換成 "TestDB6ConnectionString",把原來的 資料庫連線 DefaultConnection 註解掉。再把 sessionState mode="InProc" 換成 sessionState mode="Custom",結果如下:

Web.Config

<?xml version="1.0" encoding="utf-8"?>
<!--
  如需如何設定 ASP.NET 應用程式的詳細資訊,請前往
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
    <configSections>
        <!-- For more information on Entity Framework configuration, 
            visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework"
            type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, 
                Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            requirePermission="false" />
    </configSections>
    <system.web>
        <compilation debug="true" targetFramework="4.8" />
        <httpRuntime targetFramework="4.8" />
        <profile defaultProvider="DefaultProfileProvider">
            <providers>
                <add name="DefaultProfileProvider"
                     type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, 
                        Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                     connectionStringName="TestDB7ConnectionString" applicationName="/" />
            </providers>
        </profile>
        <membership defaultProvider="DefaultMembershipProvider">
            <providers>
                <add name="DefaultMembershipProvider"
                     type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, 
                        Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                     connectionStringName="TestDB7ConnectionString" enablePasswordRetrieval="false"
                     enablePasswordReset="true" requiresQuestionAndAnswer="false"
                     requiresUniqueEmail="false" maxInvalidPasswordAttempts="5"
                     minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"
                     passwordAttemptWindow="10" applicationName="/" />
            </providers>
        </membership>
        <roleManager defaultProvider="DefaultRoleProvider">
            <providers>
                <add name="DefaultRoleProvider"
                     type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, 
                        Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                     connectionStringName="TestDB7ConnectionString" applicationName="/" />
            </providers>
        </roleManager>
        <!--
            If you are deploying to a cloud environment that has multiple web server instances,
            you should change session state mode from "InProc" to "Custom". In addition,
            change the connection string named "TestDB7ConnectionString" to connect to an instance
            of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
      -->
        <sessionState mode="Custom" customProvider="DefaultSessionProvider">
            <providers>
                <add name="DefaultSessionProvider"
                     type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, 
                        Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                     connectionStringName="TestDB7ConnectionString" />
            </providers>
        </sessionState>
    </system.web>
    <system.codedom>
        <compilers>
            <compiler language="c#;cs;csharp" extension=".cs"
                type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, 
                  Microsoft.CodeDom.Providers.DotNetCompilerPlatform, 
                  Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                warningLevel="4"
                compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
            <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
                type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, 
                  Microsoft.CodeDom.Providers.DotNetCompilerPlatform, 
                  Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                warningLevel="4"
                compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
        </compilers>
    </system.codedom>
    <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
            <parameters>
                <parameter value="v15.0" />
            </parameters>
        </defaultConnectionFactory>
        <providers>
            <provider invariantName="System.Data.SqlClient"
                      type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
    </entityFramework>
    <connectionStrings>
        <!--<add name="TestDB7ConnectionString" connectionString="Data Source=.\SQLEXPRESS;
            Initial Catalog=aspnet-WebApplication1-20220412142205;Integrated Security=SSPI"
            providerName="System.Data.SqlClient" />-->
        <add name="TestDB7ConnectionString"
             connectionString="Data Source=.;Initial Catalog=TestDB7;Persist Security Info=True;User ID=sa;Password=P@ssw0rd"
          providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>

在 Visual Studio 2022 中 Default.aspx 按下 F5 執行,TestDB7資料庫中會自動建立 dbo.sessions 資料表。

不過說實話,它在 Web.Config 加入太多東西,敝人偏好第一種方式自己手動用 aspnet_regsql.exe 建立,除非你沒有 DB Server 的 Windows 作業系統權限,無法使用第一種方式,就只能用這種。

(完)

相關

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(一)aspnet_regsql.exe
https://shaurong.blogspot.com/2022/04/aspnet-sql-server-session-state.html

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(二)System.Web.Providers
https://shaurong.blogspot.com/2022/04/aspnet-sql-server-session-state_12.html

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(三)Microsoft.AspNet.Providers
https://shaurong.blogspot.com/2022/04/aspnet-sql-server-session-state_28.html



[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(二)System.Web.Providers

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(二)System.Web.Providers

2022-04-12

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#

續這篇

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(一)aspnet_regsql.exe
https://shaurong.blogspot.com/2022/04/aspnet-sql-server-session-state.html

用aspnet_regsql.exe需要自己手動在SQL Server建立資料表,用 NuGet 安裝 System.Web.Providers可讓系統自動在資料庫建立 dbo.sessions資料表。

先用 NuGet 安裝 System.Web.Providers 1.2.0,其實描述有說 Legacy package, System.Web.Providers is now included in the 'Microsoft.AspNet.Providers' package.,這次先不管,先安裝。它會要求安裝相依套件:

Microsoft.AspNet.Providers.Core.1.0.0

Microsoft.AspNet.Providers.1.1.0

System.Web.Providers.1.2.0

NuGet會在Web.Config建立一個資料庫連線 DefaultConnection,還有一堆設定使用該連線。

之後隨便建立一個 Default.aspx (隨便取個名稱),拖拉一個SqlDataSource控制項過去,設定資料庫連線,假設稱為 TestDB6ConnectionString。

最後把 Web.Config 中 "DefaultConnection" 字串全換成 "TestDB6ConnectionString",把原來的 資料庫連線 DefaultConnection 註解掉。再把 sessionState mode="InProc" 換成 sessionState mode="Custom",結果如下:

Web.Config

<?xml version="1.0" encoding="utf-8"?>
<!--
  如需如何設定 ASP.NET 應用程式的詳細資訊,請前往
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.8" />
    <httpRuntime targetFramework="4.8" />
    <profile defaultProvider="DefaultProfileProvider">
      <providers>
        <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="TestDB6ConnectionString" applicationName="/" />
      </providers>
    </profile>
    <membership defaultProvider="DefaultMembershipProvider">
      <providers>
        <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="TestDB6ConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>
    <roleManager defaultProvider="DefaultRoleProvider">
      <providers>
        <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="TestDB6ConnectionString" applicationName="/" />
      </providers>
    </roleManager>
    <!--
            If you are deploying to a cloud environment that has multiple web server instances,
            you should change session state mode from "InProc" to "Custom". In addition,
            change the connection string named "TestDB6ConnectionString" to connect to an instance
            of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
      -->
    <sessionState mode="Custom" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="TestDB6ConnectionString" />
      </providers>
    </sessionState>
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
  <connectionStrings>
    <!--<add name="TestDB6ConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-WebApplication1-20220412140321;Integrated Security=SSPI"
      providerName="System.Data.SqlClient" />-->
    <add name="TestDB6ConnectionString" connectionString="Data Source=.;Initial Catalog=TestDB6;Persist Security Info=True;User ID=sa;Password=P@ssw0rd"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

在 Visual Studio 2022 中 Default.aspx 按下 F5 執行,TestDB6資料庫中會自動建立 dbo.sessions 資料表。


另外下面這兩個已經出到 2.0.0版,但 System.Web.Providers 1.2.0 只會安裝 1.x版,所以需要自己手動再執行一次,把他們升級到 2.0.0 版。

Microsoft.AspNet.Providers.Core.1.0.0

Microsoft.AspNet.Providers.1.1.0

(完)

相關

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(一)aspnet_regsql.exe
https://shaurong.blogspot.com/2022/04/aspnet-sql-server-session-state.html

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(二)System.Web.Providers
https://shaurong.blogspot.com/2022/04/aspnet-sql-server-session-state_12.html


2022年4月2日 星期六

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(一)aspnet_regsql.exe

[研究][ASP.NET]使用 SQL Server 儲存 Session State 會談狀態(一)aspnet_regsql.exe

2022-03-30

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019

讓網站重新發佈(deploy),登入狀態Session依然保留,避免Session丟失,ASP.NET State Service服務是一種方式,Web.Config 中的  sessionState 預設是 InProc,改成其他方式也是可考慮的。

aspnet_regsql.exe 一般在下面目錄

system drive\Windows\Microsoft.NET\Framework\version\

例如

C:\Windows\Microsoft.NET\Framework64\v4.0.30319

C:\Windows\Microsoft.NET\Framework\v4.0.30319

C:\Windows\Microsoft.NET\Framework64\v2.0.50727

C:\Windows\Microsoft.NET\Framework\v2.0.50727

********************************************************************************

一、使用ASPState資料庫

切換目錄後,執行命令  

cd   C:\Windows\Microsoft.NET\Framework64\v4.0.30319

aspnet_regsql.exe -S SampleSqlServer -E -ssadd -sstype p

會產生一個 ASPState 資料庫,包含 ASPStateTempApplications 和 ASPStateTempSessions 資料表。


********************************************************************************

二、使用 aspnet_regsql.exe 圖形模式,建立於現有資料庫








因為 TestDB 已經有些 table,不太確定到底新增了甚麼資料表;另外新建了 TestDB2 資料庫測試,結果如下,和  ASPState  的資料庫內容差異很大。(另外測試發現,就算不使用 SQL Server驗證,改用 Windows驗證,也是新建一堆資料表)

在某個 .aspx 中拉入 SqlDataSource 控制項,設定一次資料庫連線,讓 Web.Config 自動產生相關設定,然後參考這篇在 Web.config 中增加 sessionState 相關設定

https://docs.microsoft.com/zh-tw/previous-versions/aspnet/ms178586(v=vs.100)

********************************************************************************

三、使用 aspnet_regsql.exe 命令模式,建立於現有資料庫 (推薦)

Web.Config的 sessionState 預設是 InProc,網站重新發佈(deploy)後,Session消失,登入狀態消失,必須重新登入;把 Session State 改存放到 SQL Server 是一種解決方法。下面指令把 Session改存放到 TestDB4 資料庫中。

cd    C:\Windows\Microsoft.NET\Framework64\v4.0.30319

aspnet_regsql.exe   -E   -ssadd   -sstype   c   -d   TestDB4


****************************************
如果出現
發生錯誤。例外狀況的詳細資料:
登入失敗。此登入來自未信任的網域,而且無法使用整合式驗證。

無法連接至 SQL Server 資料庫。

改用下面方式看看

cd    C:\Windows\Microsoft.NET\Framework64\v4.0.30319
aspnet_regsql.exe   -U   資料庫帳號   -P   資料庫密碼    -ssadd   -sstype   c   -d   TestDB4


****************************************
然後去資料庫檢查是否新增了2個資料表
dbo.ASPStateTempApplications
dbo.ASPStateTempSessions

****************************************

Web.Config


<?xml version="1.0" encoding="utf-8"?>
<!--
  如需如何設定 ASP.NET 應用程式的詳細資訊,請前往
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
	<connectionStrings>
		<add name="TestDB4ConnectionString" connectionString="Data Source=.;Initial Catalog=TestDB4;Persist Security Info=True;User ID=sa;Password=P@ssw0rd"
		  providerName="System.Data.SqlClient" />
	</connectionStrings>
	<system.web>
		<compilation debug="true" targetFramework="4.8" />
		<httpRuntime targetFramework="4.8" />
		<sessionState mode="SQLServer"
			  allowCustomSqlDatabase="true"
			  sqlConnectionString="TestDB4ConnectionString"
			  cookieless="false"
			  timeout="20"
		/>
	</system.web>
	<system.codedom>
		<compilers>
			<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
			<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
		</compilers>
	</system.codedom>
</configuration>

推薦原因,不會另外有一個資料庫,也不會建立一堆資料表。

 ASP.NET 的 Web.config 中將 sessionState 的 mode 設置為 "SQLServer" 時,ASP.NET 將會在資料庫中創建一個 dbo.Sessions 資料表。這個資料表將用於存儲 ASP.NET 應用程序的會話狀態數據。

dbo.Sessions 資料表通常不是由 aspnet_regsql.exe 建立的。

********************************************************************************

附錄:aspnet_regsql.exe 參數


C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regsql.exe /?
Microsoft (R) ASP.NET SQL Registration Tool 版本 4.8.3761.0
在 SQL Server 上安裝和解除安裝 ASP.NET 功能的管理公用程式。
Copyright (C) Microsoft Corporation. 著作權所有,並保留一切權利。



                                                       -- 一般選項 --

-?                         顯示這個說明文字。

-W                         精靈模式 (未指定其他參數時為預設值)。


                                                     -- SQL 連接選項 --

-S <server>                要使用的 SQL Server 執行個體 (SQL Server 7.0 以上)。

-U <login id>              用於驗證的 SQL Server 使用者名稱; 需要 -P 選項。

-P <password>              用於驗證的 SQL Server 密碼; 需要 -U 選項。

-E                         使用目前的 Windows 認證驗證。

-C <connection string>     連接字串。指定 SQL Server 連接字串,而不要指定使用者名稱、密碼,以及伺服器名稱。除非另行指定,字串中不得包含資料庫名稱。

-sqlexportonly <filename>  產生用於加入或移除指定功能的 SQL 指令碼檔案,且不執行實際作業。可搭配下列選項使用: -A、-R、-ssadd 及 -ssremove。


                                                     -- 應用程式服務選項 --

-A all|m|r|p|c|w           加入功能的支援。可同時指定多個值。例如:

                               -A mp
                               -A m -A p

                           all: 所有功能
                           m: 成員資格
                           r: 角色管理員
                           p: 使用者設定檔
                           c: 個人化
                           w: SQL Web 事件提供者

-R all|m|r|p|c|w           移除對功能的支援。可同時指定多個值。例如:

                               -R mp
                               -R m -R p

                           all : 所有功能,以及這些功能共用的所有通用資料表和預存程序
                           m: 成員資格
                           r: 角色管理員
                           p: 使用者設定檔
                           c: 個人化
                           w: SQL Web 事件提供者

-d <database>              搭配應用程式服務使用的資料庫名稱。如果沒有指定任何資料庫名稱,則會使用預設的資料庫 "aspnetdb"。

-Q                         無訊息模式; 移除功能時不顯示確認訊息。



                                           -- SQL 快取相依性選項 (SQL 7.0 和 2000) --

-d <database>              在 SQL 7.0 和 SQL 2000 中搭配 SQL 快取相依性使用的資料庫名稱。您也可以選擇改用連接字串與 -C 選項指定資料庫。(必要項)

-ed                        啟用 SQL 快取相依性的資料庫。

-dd                        停用 SQL 快取相依性的資料庫。

-et                        啟用 SQL 快取相依性的資料表。需要 -t 選項。

-dt                        停用 SQL 快取相依性的資料表。需要 -t 選項。

-t <table>                 要針對 SQL 快取相依性啟用或停用的資料表名稱。需要 -et 或 -dt 選項。

-lt                        列出所有 SQL 快取相依性啟用的資料表。


                                                     -- 工作階段狀態選項 --

-ssadd                     加入對 SQLServer 模式工作階段狀態的支援。

-ssremove                  移除對 SQLServer 模式工作階段狀態的支援。

-sstype t|p|c              工作階段狀態支援的類型:

                           t: 暫存。工作階段狀態資料會儲存到 "tempdb" 資料庫中。管理工作階段的預存程序則會安裝到 "ASPState" 資料庫中。如果您重新啟動 SQL,資料就不是永續性的。(預設)

                           p: 永續性。工作階段狀態資料和預存程序都會儲存到 "ASPState" 資料庫中。

                           c: 自訂。工作階段狀態資料和預存程序都會儲存到自訂資料庫中。您必須指定資料庫名稱。

-d <database>              當 -sstype 為 "c" 時使用的自訂資料庫名稱。

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>

********************************************************************************

(完)

相關

儲存 ASP.NET SQL Server 模式會話狀態 | Microsoft Docs
https://docs.microsoft.com/zh-tw/troubleshoot/developer/webapps/aspnet/development/configure-sql-store-session-state
https://docs.microsoft.com/en-us/troubleshoot/developer/webapps/aspnet/development/configure-sql-store-session-state

Session-State Modes | Microsoft Docs
https://docs.microsoft.com/zh-tw/previous-versions/ms178586(v=vs.140)?redirectedfrom=MSDN
aspnet_regsql.exe -S SampleSqlServer -E -ssadd -sstype p

ASP.NET程式中Session儲存的幾種模式 - IT閱讀
https://www.itread01.com/content/1546942022.html