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

System.Web.HttpException - when using session state and context.It

P: n/a
I am getting the following error:
Run-time exception thrown : 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

Session state is enabled throughout the application.

This is occuring after I do a server.transfer and I am passing details
between my 2 pages using Context.Items collection. It would appear theuse of
the Context.Items collection is causing this problem as it was not occurring
when I used Response.Redirect and a query string

Any ideas?

Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
This is from inside the processing of an ASPX page?
Do you know the exact line of code where the exception is thrown?

--
Scott
http://www.OdeToCode.com/blogs/scott/
I am getting the following error:
Run-time exception thrown : 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
Session state is enabled throughout the application.

This is occuring after I do a server.transfer and I am passing details
between my 2 pages using Context.Items collection. It would appear
theuse of the Context.Items collection is causing this problem as it
was not occurring when I used Response.Redirect and a query string

Any ideas?

Nov 19 '05 #2

P: n/a
I realised this seemed to happen after doing Context.Items.Clear but it also
seems to happen on other occasions - for example these lines of code:

Context.Items("strForm") = "Message"
Context.Items("strMessage") = "Registration Cancelled"
Context.Items("UpdateTree") = "True"
Server.Transfer("frmMessage.aspx")

In frmMessage there is a user control which reads information from a session
variable and this line of code falls over with the error:
If Session("SecurityInfo") Is Nothing Then --FALLS OVER HERE
Response.Redirect("Default.aspx")
End If

"Scott Allen" wrote:
This is from inside the processing of an ASPX page?
Do you know the exact line of code where the exception is thrown?

--
Scott
http://www.OdeToCode.com/blogs/scott/
I am getting the following error:
Run-time exception thrown : 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
Session state is enabled throughout the application.

This is occuring after I do a server.transfer and I am passing details
between my 2 pages using Context.Items collection. It would appear
theuse of the Context.Items collection is causing this problem as it
was not occurring when I used Response.Redirect and a query string

Any ideas?


Nov 19 '05 #3

P: n/a
This is a better example:

In the Page Load event of the user conmtrol I have this code:
If Not Page.IsPostBack Then
lblUserName.Text = Session.Item("SecurityInfo").UserFullName
lblUserRole.Text = Session.Item("SecurityInfo").Role
subFillProfessionCombo()

RaiseEvent SecurityDetailsLoaded()
End If

The user control is placed on 2 different forms. When I do a
Server.transfer to one form it works Ok, but when I do a Server.Transfer to
the other one I get the exception. I can't seen any obvioud differences
between the two forms.
Thanks
Siobhan

"Siobhan" wrote:
I realised this seemed to happen after doing Context.Items.Clear but it also
seems to happen on other occasions - for example these lines of code:

Context.Items("strForm") = "Message"
Context.Items("strMessage") = "Registration Cancelled"
Context.Items("UpdateTree") = "True"
Server.Transfer("frmMessage.aspx")

In frmMessage there is a user control which reads information from a session
variable and this line of code falls over with the error:
If Session("SecurityInfo") Is Nothing Then --FALLS OVER HERE
Response.Redirect("Default.aspx")
End If

"Scott Allen" wrote:
This is from inside the processing of an ASPX page?
Do you know the exact line of code where the exception is thrown?

--
Scott
http://www.OdeToCode.com/blogs/scott/
I am getting the following error:
Run-time exception thrown : 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
Session state is enabled throughout the application.

This is occuring after I do a server.transfer and I am passing details
between my 2 pages using Context.Items collection. It would appear
theuse of the Context.Items collection is causing this problem as it
was not occurring when I used Response.Redirect and a query string

Any ideas?


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.