Session Variables - Returns Error

J

Jennifer

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
 
J

Joe Glover

Hi Jennifer

Is the line

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

declared at class level, or inside a Page event handler? It won't work at
class level. If this is the case then you need to declare your string, but
not access the session until Page_Init or Page_Load event occurs.

Does this help?
Joe
 
J

Jennifer

-----Original Message-----
have u tried using
dim str as string = session("gstrpassword")


.

Joe directed me to get the values in the Page Load Event
instead of where I declared them as Module Level
Variables. That Worked.

Thank you for your response!
 
J

Jennifer

THANK YOU!!!

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.

THANK YOU!!! This has been killing me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top