473,804 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Web.Http Exception - when using session state and context.It

I am getting the following error:
Run-time exception thrown : System.Web.Http Exception - Session state can
only be used when enableSessionSt ate 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.Redire ct and a query string

Any ideas?

Nov 19 '05 #1
3 2494
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.Http Exception - Session state
can
only be used when enableSessionSt ate 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.Redire ct and a query string

Any ideas?

Nov 19 '05 #2
I realised this seemed to happen after doing Context.Items.C lear but it also
seems to happen on other occasions - for example these lines of code:

Context.Items(" strForm") = "Message"
Context.Items(" strMessage") = "Registrati on Cancelled"
Context.Items(" UpdateTree") = "True"
Server.Transfer ("frmMessage.as px")

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("Securi tyInfo") Is Nothing Then --FALLS OVER HERE
Response.Redire ct("Default.asp x")
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.Http Exception - Session state
can
only be used when enableSessionSt ate 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.Redire ct and a query string

Any ideas?


Nov 19 '05 #3
This is a better example:

In the Page Load event of the user conmtrol I have this code:
If Not Page.IsPostBack Then
lblUserName.Tex t = Session.Item("S ecurityInfo").U serFullName
lblUserRole.Tex t = Session.Item("S ecurityInfo").R ole
subFillProfessi onCombo()

RaiseEvent SecurityDetails Loaded()
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.C lear but it also
seems to happen on other occasions - for example these lines of code:

Context.Items(" strForm") = "Message"
Context.Items(" strMessage") = "Registrati on Cancelled"
Context.Items(" UpdateTree") = "True"
Server.Transfer ("frmMessage.as px")

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("Securi tyInfo") Is Nothing Then --FALLS OVER HERE
Response.Redire ct("Default.asp x")
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.Http Exception - Session state
can
only be used when enableSessionSt ate 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.Redire ct and a query string

Any ideas?


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6332
by: DC Gringo | last post by:
I'm having such a problem with this DropDownList in a user control that is posting back and throwing an error: System.Web.HttpException: A DropDownList cannot have multiple items selected <ASP:DROPDOWNLIST ID="lbCountriesWiz" ENABLEVIEWSTATE="true" FONT-SIZE="8pt" ONSELECTEDINDEXCHANGED="ddlQueryProvinces" AUTOPOSTBACK="True" RUNAT="server" WIDTH="150px"></ASP:DROPDOWNLIST> Private Sub Page_Load(ByVal sender As System.Object, ByVal...
0
3456
by: matt | last post by:
I've come across a real problem and am totally stuck as to why this is happening, hoping desperately that someone else has experienced the same thing, and knows a solution! Session state should be available from the PrequestHandlerExecute event, and is most of the time for me however sometimes asp.net appears not to load session state at this stage. We have a HttpModule which runs fine 99% of the time however sometimes we have a problem...
0
1418
by: Ryan | last post by:
Hello I AM POSTING THIS WITH THE INTENT TO HELP SOMEONE ELSE WHO MAY HAVE THIS PROBLEM.... I DONT NEED HELP ;) I was getting the following error in one of my applications which was installed on another computer. At first I could not find the reason this error was happening; however, after some testing I realized this is the error that will show up when debugging isn't on and there in an error on the aspx part of the page.
2
3767
by: David Berman | last post by:
It seems that my site is losing session information when using Server.Transfer. I have a page called PictureGallery.aspx. It takes an argument which is an index id, so it would look like PictureGallery.aspx?id=30 to display gallery 30. In this way I have a database driven picture gallery. To improve indexing, I put code in Global.asax to allow me to get to the same page with a url like this: Pictures_30.aspx. There is no...
8
1837
by: A P | last post by:
Hi! I'm using ASP.Net Web Matrix on my PC and wanting to publish the files to our server. I try to copy (thru explorer) the files but it didn't work! I receive Runtime Error: Server Error in '/' Application. ---------------------------------------------------------------------------- ----
5
8328
by: dpomt | last post by:
I have overwritten Application_Error in my GlobalAsax to handle errors. From time to time, I am getting exceptions I have never seen before (see below). What do this exceptions mean? Why are they generated? Any help would be greatly appreciated. Dieter
0
1722
by: Jeremy Chapman | last post by:
I am thinking of implementing System.Web.UI.SessionPageStatePersister as a method of storing viewstate in the session. Before I do, I am browsing threw the class's code using reflector just to get an understanding of performance/memory hits on the server. I've attached the code below, and my understanding of it is less that what I like. Is there anyone here with a more familiar knowledge of how it works? I'm wondering how it cleans up...
0
2676
by: JT | last post by:
This seems like it could be an asp.net bug. I am getting the following exception when I add OnSortCommand attribute to a datagrid. I have deleted the temp directories, rebooted etc and I have isolated it to the OnSortCommands presence. When I use a code behind it doesn't fire any events on the back end and the global error handler grabs it. I put together a very simple example to illustrate the problem below. If anyone has an idea of...
2
6321
by: Zeb | last post by:
Quick question! I'm using Global.aspx in my web app to catch unhandled exceptions, log them and redirect the user to a "something went wrong" page. This means that at the moment, if the user visits a page that doesn't exist, they're taken to the generic error page ... but I'd much rather let them know that the page wasn't found and that they might like to double check the url.
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.