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

G

Guest

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?
 
S

Scott Allen

This is from inside the processing of an ASPX page?
Do you know the exact line of code where the exception is thrown?
 
G

Guest

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
 
G

Guest

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
 

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,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top