Jack
Jack

Reputation: 363

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

Upvotes: 16

Views: 48414

Answers (6)

Ali Tayyip Aydin
Ali Tayyip Aydin

Reputation: 43

"The cause of this error if you didn’t give enough permission to the user that accesses the database. User should have execute permissions or grant dbo.owner to it."

**IF YOU TRY THİS SOLUTION IT WILL BE SOLVED enter image description here

Source : link1

Upvotes: 2

Jason Geiger
Jason Geiger

Reputation: 2112

All this information is extremely valuable but there are a couple more valuable notes depending on your situation.

If you ran the wizard it does not run with the -ssadd flag. The -ssadd flag is what creates the dbo.TempGetVersion procedure and other procedures as well.

If you are going to a custom server/database you will want to run the program as follows...

aspnet_regsql.exe -S YourServerName -d YourDatabaseName -ssadd -E -sstype c
  • -S is your servername flag
  • -D is your database name flag
  • -ssadd Adds support for SQLServerm mode session state. Run -ssremove if you need to remove the procedures.
  • -E uses the current Windows credentials to connect to the target database to set things up.
  • -sstype c says that this is a custom database name.

Upvotes: 13

Rolando Retana
Rolando Retana

Reputation: 492

I was stuck with this and none of the answers worked for me, just in case someone else have this problem, this was what solved my problem, I ran in the cmd:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regsql.exe -C "Data Source=.\SQL2012;Integrated Security=True" -ssadd

Just in case someone else gets stuck in the same situation as me.

Upvotes: 2

Kenn
Kenn

Reputation: 2769

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.

Upvotes: 39

user2167048
user2167048

Reputation: 41

Maybe you have a bad tag in your web.config

A correct example should be:

<sessionState 
allowCustomSqlDatabase="true" 
mode="SQLServer" 
sqlConnectionString="data source=localhost;initial catalog=YourAspStateDatabase;user id=yourLogin;password=yourpassword" cookieless="false" timeout="30"/>

Upvotes: 4

Pleun
Pleun

Reputation: 8920

Open "Programmability" in your tree and check first if dbo.TempGetVersion exists. Probably you have not installed the proper schema.

Upvotes: 5

Related Questions