473,322 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

sessions in class instance of an object

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"];
}

Nov 16 '05 #1
1 4568
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"mike" <sp******@hotmail.com> wrote in message
news:hH******************@front-1.news.blueyonder.co.uk...
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"];
}


Nov 16 '05 #2

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

Similar topics

11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
2
by: Earl Teigrob | last post by:
I am using C# to program ASP.NET. I am using class of static fields to hold all variables that are common to the application, and I am sure that this is fine. However, I was also using some static...
5
by: Rob | last post by:
I have an ASP.NET application that uses forms-based authentication. A user wishes to be able to run multiple sessions of this application simultaneously from the user's client machine. The...
4
by: Christina N | last post by:
Can anyone give me a code example of how to use a global array to keep track of all active sessions (their sessionid, logontime, etc)? I need a code example, not a prosa description of what to...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
1
by: Nick Wouters | last post by:
Dear all I sended this reply to my first issue a few days ago... please help!!! ----------------------------------------------------------------------------- correct, but when I am using...
2
by: Mikael stberg | last post by:
Hello all! I have this login function which doesn't work really well. I tried to do extend the built-in functionality in order to store things such as userName and email address in Session. ...
3
by: Atul | last post by:
Hi, I am running .NET Framework 2.0 on windows XP SP2. I am stuck in a situation where I need to find out a list of all active sessions running in IIS for a web application. I know that .NET...
5
by: Andy | last post by:
I have an admin section of my asp.net 2 application, and I want to be able to automatically login as a different user (Forms Authentication) whilst keeping my current session going too. The problem...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.