sessions in class instance of an object

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

I've got a class Users.
inside of which i'm trying to see if my session is not null
i keep getting an error: on this line:

if(HttpContext.Current.Session["StoreID"] == null)
"Object reference not set to an instance of an object"

Can anyone point me in a direction to get this fixed?
Thanks in Advance
Mike


Code:---
if((string)HttpContext.Current.Application["storeID"] == "error")
{
if(HttpContext.Current.Session["StoreID"] == null)
{
StoreID = "1";
}

StoreID = HttpContext.Current.Session["StoreID"].ToString();
}
else
{
StoreID = (string)HttpContext.Current.Application["storeID"];
}
 
Mike,

Are you using your User property on another thread, or outside of
ASP.NET? If so, then the static Current property of the HttpContext class
will return null, as (I believe) an HttpContext has thread affinity.

Hope this helps.
 

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

Back
Top