Session variable problem

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

David Waz...

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...
 
J

Jason

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
.
.
 

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

Forum statistics

Threads
474,078
Messages
2,570,570
Members
47,204
Latest member
MalorieSte

Latest Threads

Top