Can't get Session variables to work

  • Thread starter Thread starter AAaron123
  • Start date Start date
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>
 
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?
 
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.
 
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.
 
Back
Top