Can't get Session variables to work

A

AAaron123

THIS ERROR :
Session state can only be used when enableSessionState is set to true,
either in a configuration file or in the Page directive. Please also make
sure that System.Web.SessionStateModule or a custom session state module is
included in the <configuration>\<system.web>\<httpModules> section in the
application configuration.
WAS PRODUCED BY THIS CODE:

Line 6: Dim directorySeparatorChar As Char =
Path.DirectorySeparatorChar
Line 7: 'Dim root As String = "C:\Documents and
Settings\Cal\Desktop\JUNKUploaded"
Line 8: Dim root As String = Session("UploadServerRootFolder")
Line 9:
Line 10: Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Load

SO I ADDED THE CODE BELOW BUT THAT DOES NOT FIX IT.
I ALSO TRIED ADDING EnableSessionState="True" to: <%@ Page ...
ALSO TRIED WITHOUT THE <remove name="Session"/>

GOT ANY IDEA WHAT ELSE I CAN TRY?

THANKS

....
<httpModules>
....
<remove name="Session"/>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
</httpModules>
<sessionState mode="InProc" cookieless="true" timeout="20"/>
</system.web>
 
G

Guest

THIS ERROR :
Session state can only be used when enableSessionState is set to true,
either in a configuration file or in the Page directive. Please also make
sure that System.Web.SessionStateModule or a custom session state module is
included in the <configuration>\<system.web>\<httpModules> section in the
application configuration.
WAS PRODUCED BY THIS CODE:

Line 6:      Dim directorySeparatorChar As Char =
Path.DirectorySeparatorChar
Line 7:      'Dim root As String = "C:\Documents and
Settings\Cal\Desktop\JUNKUploaded"
Line 8:      Dim root As String = Session("UploadServerRootFolder")
Line 9:
Line 10:     Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Load

SO I ADDED THE CODE BELOW BUT THAT DOES NOT FIX IT.
I ALSO TRIED ADDING EnableSessionState="True"  to: <%@ Page ...
ALSO TRIED WITHOUT THE <remove name="Session"/>

GOT ANY IDEA WHAT ELSE I CAN TRY?

THANKS

...
<httpModules>
...
<remove name="Session"/>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
</httpModules>
<sessionState mode="InProc" cookieless="true" timeout="20"/>
</system.web>

what happen if you remove


from the web.config?
 
A

AAaron123

THIS ERROR :
Session state can only be used when enableSessionState is set to true,
either in a configuration file or in the Page directive. Please also make
sure that System.Web.SessionStateModule or a custom session state module
is
included in the <configuration>\<system.web>\<httpModules> section in the
application configuration.
WAS PRODUCED BY THIS CODE:

Line 6: Dim directorySeparatorChar As Char =
Path.DirectorySeparatorChar
Line 7: 'Dim root As String = "C:\Documents and
Settings\Cal\Desktop\JUNKUploaded"
Line 8: Dim root As String = Session("UploadServerRootFolder")
Line 9:
Line 10: Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Load

SO I ADDED THE CODE BELOW BUT THAT DOES NOT FIX IT.
I ALSO TRIED ADDING EnableSessionState="True" to: <%@ Page ...
ALSO TRIED WITHOUT THE <remove name="Session"/>

GOT ANY IDEA WHAT ELSE I CAN TRY?

THANKS

...
<httpModules>
...
<remove name="Session"/>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
</httpModules>
<sessionState mode="InProc" cookieless="true" timeout="20"/>
</system.web>

what happen if you remove


from the web.config?

==

I started without them and added them per the error instructions.
 
A

AAaron123

Dim root As String = Session("UploadServerRootFolder")

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

The above caused the problem.

The below works OK.

It would be great to know why that is so.

Dim root As String

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

Dim root As String = Session("UploadServerRootFolder")

Any way I pass it on for what ever it might be worth to someone.
 
Joined
May 13, 2009
Messages
1
Reaction score
0
Thanks

Thanks, this fixed my problem (well, one of the more nagging one's at least). Your observation and posting of it helped me a lot!
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top