By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,251 Members | 2,764 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,251 IT Pros & Developers. It's quick & easy.

Session state not working

P: n/a
Hello Everyone,

I have a confusing problem. I'm getting the following error
message on an ASPX page ...

Session state can only be used when enableSessionState is set to true,
either in a configuration file or in the Page directive

I've seen it before and figured something was shut off. I checked
and by default the session state is turned ON. I've got the web.config
setup for session state as follows ...

<sessionState
mode = "SqlServer"
sqlConnectionString="data source=localhost;Integrated
Security=SSPI;Initial Catalog=ASPState"
cookiesless="false"
timeout="20"/>

I'm at a bit of a loss as to what's happening. According to the
code and setup, session state should be working. Am I missing
something? what else can I check?

Thank you in advance for any assistance,
Scott Vercuski

Apr 12 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi, Scott.

Have you verified that there's localhost access to the SQL Server in question ?

Check to see if your SQL Server is accesible via "localhost".

SQL Server connection strings to "(local)" are quite common, but not to "localhost".
Sql Server connections to "localhost" are much less common.

Try using "data source=(local);" instead of "data source=localhost;" in the connection string
and see if that allows access to your SQL Server.

Also, you could try testing with sessionState set to "InProc", just for test purposes.
If that gets your sessionState working, the problem is -definitely- access to SQL Server.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<lu****@gmail.com> wrote in message news:11*********************@u72g2000cwu.googlegro ups.com...
Hello Everyone,

I have a confusing problem. I'm getting the following error
message on an ASPX page ...

Session state can only be used when enableSessionState is set to true,
either in a configuration file or in the Page directive

I've seen it before and figured something was shut off. I checked
and by default the session state is turned ON. I've got the web.config
setup for session state as follows ...

<sessionState
mode = "SqlServer"
sqlConnectionString="data source=localhost;Integrated
Security=SSPI;Initial Catalog=ASPState"
cookiesless="false"
timeout="20"/>

I'm at a bit of a loss as to what's happening. According to the
code and setup, session state should be working. Am I missing
something? what else can I check?

Thank you in advance for any assistance,
Scott Vercuski

Apr 12 '06 #2

P: n/a
Juan,

Thank you for your reply!

I originally had the session state set at inProc and it was still
giving me the same error.

I tried your suggestion and changed the localhost to the SQL
Instance name to no avail. I still get the same message.

Thank you,
Scott Vercuski

Apr 12 '06 #3

P: n/a
Hi, Scott.

A few more things to check :

1. Is this a typo ? : cookiesless="false"
That should be : cookieless="false"

2. Could you check to see if you can connect to another database in your
SQL Server using either "localhost", "(local)", or "Instance_name" ?

3. Check your connection string. You are not using case-sensitive strings.

<configuration>
<system.web>
<sessionState mode="SQLServer"
sqlConnectionString="Integrated Security=SSPI;data source=SampleSqlServer;" />
</system.web>
</configuration>

If you specify a trusted connection to your SQL Server in the configuration file using the
sessionState element's sqlConnectionString attribute, the SessionStateModule will connect
to SQL Server using SQL Server integrated security. The connection will be made using
the ASP.NET process identity or the user credentials supplied for the identity configuration
element, if they exist.

4. Did you run the Aspnet_regsql.exe Tool ?

Follow the instructions at :
http://windowssdk.msdn.microsoft.com...8b9b591bb4.asp

if you haven't installed the SQL Server database with the Aspnet_regsql.exe tool.

Let us know what you did, and how it came out, OK ?

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<lu****@gmail.com> wrote in message news:11********************@t31g2000cwb.googlegrou ps.com...
Juan,

Thank you for your reply!

I originally had the session state set at inProc and it was still
giving me the same error.

I tried your suggestion and changed the localhost to the SQL
Instance name to no avail. I still get the same message.

Thank you,
Scott Vercuski


Apr 12 '06 #4

P: n/a
Juan,

Sorry the cookiesless was a typo on my part. It's correct in the
web.config file.

I've been told by my supervisor to go back to the InProc state
instead of SQL but I'm still getting the same error. What might cause
the error even through everything appears to be configured correctly?

Thanks,
Scott

Apr 12 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.