Answered by:
Where are my sql tables for state management?

Question
-
User626947523 posted
I am working on an asp.net form-based web app which will be deployed to Azure. I saw the following text in the web.config file.
<!--
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 "DefaultConnection" to connect to an instance
of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express.
-->So I updated my web.config code to be like that.
<sessionState mode="Custom" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider" connectionStringName="DefaultConnection" />
</providers>
</sessionState>The "DefaultConnection" is a valid SQL Server connection.
I ran the web app via the Visual Studio IIS Express and it worked fine. But I am curious whether this app really uses my SQL Server for storing Session State. In the SQL db (specified by DefaultConnection"), I did not see any new tables created. I saw five tables created for asp.net Membership.
AspNetRoles
AspNetUserClaims
AspNetUserLogins
AspNetUserRoles
AspNetUsersI read somewhere about InstallSqlSate.sql script. So am I supposed to see some table like "dbo.ASPStateTempSessions"? In addition, I did not see any new stored procedures in my SQL database either.
Thanks.
Saturday, December 26, 2020 5:13 AM
Answers
-
User1535942433 posted
Hi nathan724,
Accroding to your description,I find a example like your codes:
https://www.c-sharpcorner.com/article/moving-mvc-session-state-in-azure/
In this article,it use ASP.NET Universal Providers nuget package to replace SQL Azure.As far as I think, everything is encapsulated in the package including tables.
I suggest you could use SQL Azure.
1.Set the mode attribute of the <sessionState> element to SQLServer to indicate that session state is stored in SQL Server.
2.Set the sqlConnectionString attribute to specify the connection string for SQL Server.
3.In SQL Query Analyzer, on the File menu, select Open.
4.In the Open Query File dialog box, browse to the InstallSqlState.sql script file, and then select Open. By default, InstallSqlState.sql is located in one of the following folders:
system drive\WINNT\Microsoft.NET\Framework\version\ system drive\Windows\Microsoft.NET\Framework\version\
5.After InstallSqlState.sql opens in SQL Query Analyzer, select Execute on the Query menu to run the script.
6.Before you run the UninstallSqlState.sql script file to uninstall SQL Server mode session state management configuration, you must stop the w3svc process. To do this, follow these steps:
- On the Windows Start menu, select Run, type cmd, and then select OK to open a command prompt.
- At the command prompt, type net stop w3svc. You receive confirmation that the w3svc process is stopped.
7.In SQL Query Analyzer, on the File menu, select Open.
8.In the Open Query File dialog box, browse to the UninstallSqlState.sql script file, and then select Open. By default, UninstallSqlState.sql is located in one of the following folders:
system drive\WINNT\Microsoft.NET\Framework\version\ system drive\Windows\Microsoft.NET\Framework\version\
9.After UninstallSqlState.sql opens in SQL Query Analyzer, select Execute on the Query menu to run the script.
10.After you uninstall SQL Server mode session state management configuration, you must restart the w3svc service. To restart the w3svc process, type net start w3svc at a command prompt.
More details,you could refer to below article:
https://docs.microsoft.com/en-us/troubleshoot/aspnet/configure-sql-store-session-state
Best regards,
Yijing Sun
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 28, 2020 6:08 AM
All replies
-
User1535942433 posted
Hi nathan724,
Accroding to your description,I find a example like your codes:
https://www.c-sharpcorner.com/article/moving-mvc-session-state-in-azure/
In this article,it use ASP.NET Universal Providers nuget package to replace SQL Azure.As far as I think, everything is encapsulated in the package including tables.
I suggest you could use SQL Azure.
1.Set the mode attribute of the <sessionState> element to SQLServer to indicate that session state is stored in SQL Server.
2.Set the sqlConnectionString attribute to specify the connection string for SQL Server.
3.In SQL Query Analyzer, on the File menu, select Open.
4.In the Open Query File dialog box, browse to the InstallSqlState.sql script file, and then select Open. By default, InstallSqlState.sql is located in one of the following folders:
system drive\WINNT\Microsoft.NET\Framework\version\ system drive\Windows\Microsoft.NET\Framework\version\
5.After InstallSqlState.sql opens in SQL Query Analyzer, select Execute on the Query menu to run the script.
6.Before you run the UninstallSqlState.sql script file to uninstall SQL Server mode session state management configuration, you must stop the w3svc process. To do this, follow these steps:
- On the Windows Start menu, select Run, type cmd, and then select OK to open a command prompt.
- At the command prompt, type net stop w3svc. You receive confirmation that the w3svc process is stopped.
7.In SQL Query Analyzer, on the File menu, select Open.
8.In the Open Query File dialog box, browse to the UninstallSqlState.sql script file, and then select Open. By default, UninstallSqlState.sql is located in one of the following folders:
system drive\WINNT\Microsoft.NET\Framework\version\ system drive\Windows\Microsoft.NET\Framework\version\
9.After UninstallSqlState.sql opens in SQL Query Analyzer, select Execute on the Query menu to run the script.
10.After you uninstall SQL Server mode session state management configuration, you must restart the w3svc service. To restart the w3svc process, type net start w3svc at a command prompt.
More details,you could refer to below article:
https://docs.microsoft.com/en-us/troubleshoot/aspnet/configure-sql-store-session-state
Best regards,
Yijing Sun
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 28, 2020 6:08 AM -
User626947523 posted
Yijing,
Thanks for your reply and the resource URL is just what I need. I did find the Sessions table in my Azure SQL db. So indeed a SQL table has been created for the session state.
If I understand it correctly, the steps you provided are for SQL Server on Azure, where I have control over the VM. But I only have SQL Azure, so I need to customize those install scripts to make them work with an existing database. Although I understand that a dedicated Azure db (as prescribed in your steps) will provide better session state management than a SQL table in a share db, the "ASP.NET Universal Providers" is an easy implementation and I will go with it now until I need to scale up my app.
Thanks again for your help and Happy New Year.
Regards.
Thursday, December 31, 2020 2:00 AM