Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net session state mode "SQLServer"

"My website is LIVE. And this problem is related to configure session timeout on LIVE server and not in localhost."

I have a problem with session expiring too soon. link in 2-5 minutes only. I tried lot of things and at last decided to store the session in "SQL Server" mode

in my web.config file i have following coding:

<sessionState mode="SQLServer" cookieless="false" timeout="45"
sqlConnectionString="data source=xxx.xx.xx.xxx;uid=xxxxxxx;pwd=xxxxxxxx"/>

and i have all the tables required in ASPState table on server. You can see it from the image below.

enter image description here

But i when i run my application, its throws the below error:

"Unable to use SQL Server because either ASP.NET version 2.0 Session State is not installed on the SQL server, or ASP.NET does not have permission to run the dbo.TempGetVersion stored procedure. If the ASP.NET Session State schema has not been installed, please install ASP.NET Session State SQL Server version 2.0 or above. If the schema has been installed, please grant execute permission on the dbo.TempGetVersion stored procedure to either the ASP.NET application pool identity, or the Sql Server user specified in the sqlConnectionString attribute."

Image of the error:

enter image description here

I am not able to understand the exact problem and how i can solve it. Any help will be appreciated.

Thank You

like image 507
Jack Avatar asked Mar 13 '13 08:03

Jack


People also ask

How does SQL Server session state works?

The session state is stored in the ASPState database. The advantage of this method is that the data is persisted even if you restart the SQL server. Custom storage: Both the session state data and the stored procedures are stored in a custom database. The database name must be specified in the configuration file.

How do I change my session state to InProc?

The InProc Session State Mode is the default session mode but you can also set the Session State Mode and session timeout in the Web. Config file of you application as in the following code snippet. The preceding session timeout setting keeps the session alive for 25 minutes.


1 Answers

In order to get this to work for me I ran the command with the following options.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regsql.exe -S . -E -ssadd -sstype p

I believe the -ssadd option ("Adds support for SQL Server mode session state.") is what caused it to properly set up the stored procedures. See this link for to complete list of option.

like image 119
Kenn Avatar answered Sep 27 '22 23:09

Kenn