Session variable problem

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

I have a Session object set on Session_Start...
I figured out that the object is never created...
Cannot understand why..

Also I noticed that the debugger will not stop at
breakpoints that are inside the Session_Start method or in
the class of the object that is created within the
Session_Start method...

Is this a bug or a setting problem?
any ideas?
 
I think you might be misunderstanding the message.
The message is probably referring to the Session object
being nothing, not the content.

Session will never bomb out on an object being nothing in
the context you show. Session will be nothing in any
classes you create. Instead,
use "Current.Session.item..." and you should be able to
get your object just fine.

It helps to put a reference to:
System.Web.HttpContext
in your "Imports" in the project properties under the
properties page, Common Properties folder. Otherwise you
need to reference System.Web.HttpContext.Current.Session

Email if you need more...
 
I dont understand where to put the reference of
System.Web.HttpContext to. Is there such thing? On my
project properties page there no such thing as "Imports"
under Common Properties. I couldnt find anything like that.
Even in the code if I do "using System.Web." there is not
HttpContext...

Am I missing something here?

-----Original Message-----
I think you might be misunderstanding the message.
The message is probably referring to the Session object
being nothing, not the content.

Session will never bomb out on an object being nothing in
the context you show. Session will be nothing in any
classes you create. Instead,
use "Current.Session.item..." and you should be able to
get your object just fine.

It helps to put a reference to:
System.Web.HttpContext
in your "Imports" in the project properties under the
properties page, Common Properties folder. Otherwise you
need to reference System.Web.HttpContext.Current.Session

Email if you need more...
-----Original Message-----
Ok...

in Global.asax I have:

protected void Session_Start(Object sender, EventArgs e)
{
cms.errorHandler error = new cms.errorHandler();
Session["error"] = error;
}

and then in my code I have:

errorHandler error = (errorHandler)Session["error"];

I get:
Object Reference not set to an instance of an object
(NullReferenceException).

I even get the Exception if I do:

Session["test"] = "Test";

Yes I debug the application
.
.
 
Back
Top