Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Variables - Return Error

Status
Not open for further replies.

jzelhart

Programmer
Feb 10, 2003
469
US
I get the following error when I try to retrieve Session
Variables using this code:

Dim mstrPassword As String = CType(Session.Item
("gstrPassword"), String)

Exception Details: System.Web.HttpException: Session
state can only be used when enableSessionState is set to
true, either in a configuration file or in the Page
directive

According to everything that I have read and found this
is set to true. I have manually set it - checked in IS.

Does anyone have any ideas?

THANKS!

Jennifer
 
In your web.config file you should have a section like this
<sessionState
mode=&quot;InProc&quot;
cookieless=&quot;false&quot;
timeout=&quot;20&quot;
/>

I believe the mode=&quot;InProc&quot; is the property that your looking for. Make sure that bit is in your web.config file.




That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
<sessionState
mode=&quot;InProc&quot;
stateConnectionString=&quot;tcpip=127.0.0.1:42424&quot;
sqlConnectionString=&quot;data source=127.0.0.1;Trusted_Connection=yes&quot;
cookieless=&quot;true&quot;
timeout=&quot;20&quot;

/>
 
I also tried changing it to

<sessionState
mode=&quot;InProc&quot;
cookieless=&quot;false&quot;
timeout=&quot;20&quot;

/>

but still got the message.

I hit submit too fast sorry!

Thanks for helping :)
 
No prob. Your first post is the correct bit for the session state section. I had just clipped it a bit to shorten the post. Not sure what it could be but I'll try to look into it and will let you know what I find.

That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Thank you, I am stumped - as you can tell I am new to .Net - as a matter of fact this is my first .Net Application.

I am off for the holiday weekend but I will hopefully here from you or anyone else that has an idea next week.

Have a wonderful weekend!

Jennifer
 
Does your page directive explicitly set enableSessionState to false?

That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
The following is my page directive.

<%@ Page Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot; Codebehind=&quot;webLogin.aspx.vb&quot; Inherits=&quot;CustomerSupport.webLogin&quot;%>

I have tried explicitly setting it to true here as well as the web.config but neither together or separatly helped.

Could I be missing something on the IIS side?

Thanks,

Jennifer
 
You've got me stumped on this Jennifer sorry. I'll see what I can dig up, in the mean time hopefully a fellow member will have some ideas.

That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Thanks Mark!

Is there any other way to store information between pages. I am trying to save the users Login, Password and Software Selection. This is a customer support site.
 
Found out what I was doing wrong...

I needed to move the setting mstrPassword equal to the Session Variable to the Page Load instead of where I dim
the Module Level Variable.

Learning is such fun but VB.Net looks like it will be well worth it.
 
congrats!

That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top