Asp.Net Web Forms SQL Server Session state mode

Asp.Net Web Forms SQL Server Session state mode

Create session state database

aspnet_regsql.exe -S . -U sa -P sa@123 -d TestSession -ssadd -sstype c


-ssadd means to add the Session database
-ssremove?? means to remove the Session database.

-sstype
t => Store session data in the SQL Server tempdb database. This is the default setting. If you store the session data in the tempdb database, you will lose the session data when you restart SQL Server.
p => Store session data in the ASPState database instead of in the tempdb database.
c => Store session data in a custom database. If you specify the c option, you must also use the -d option to include the name of the custom database
        

Important Step:

The SessionId includes two parts: the 24-bit SessionID and 8-bit AppName generated by the website. For different sites, the AppName is different. In the case that the 24-bit SessionID can be made the same under different sites, ensure that the AppName is added after the combination. The SessionID is the same. You can modify the TempGetAppID stored procedure so that the SessionID obtained is independent of the AppName. Modify TempGetAppID as follows:

alter Store Procedure : TempGetAppID? SET @appName = 'Test'        

web.config

<system.web>
??? <machineKey validationKey="86B6275BA31D3D713E41388692FCA68F7D20269411345AA1C17A7386DACC9C46E7CE5F97F556F3CF0A07159659E2706B77731779D2DA4B53BC47BFFD4FD48A54" decryptionKey="9421E53E196BB56DB11B9C25197A2AD470638EFBC604AC74CD29DBBCF79D6046" validation="SHA1" decryption="AES" />
<sessionState mode="SQLServer" sqlConnectionString="Data Source=.;Initial Catalog=TestSession;Persist Security Info=True;User ID=sa;Password=sa@123" allowCustomSqlDatabase="true" cookieless="false" timeout="100"/>
</system.web>???
        


GitHub Link


要查看或添加评论,请登录

社区洞察

其他会员也浏览了