473,811 Members | 3,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HttpContext.Cur rent.Session is throwing exception(Objec t reference not set to an inst

2 New Member
In our application we have to access session objects in business class. We are using HttpContext.Cur rent.Session to get the session value. In some cases it returns the value but mostly its throwing a null reference exception(Objec t reference not set to an instance of an object). We have the following code
Try

If HttpContext.Cur rent.Session("U sername") IsNot Nothing then
' Statements to be executed
End If
Catch ex As Exception
'Log to db
End Try

Here HttpContext.Cur rent.Session("U sername") is mostly throwing an exception "Object reference not set to an instance of an object"
While debugging we found that HttpContext.Cur rent itself is nothing.

Thanks. Any help on this will be appreciated.
Sep 8 '10 #1
0 1838

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3347
by: moondaddy | last post by:
I need to set a variable to a session variable (if that's what you call it) like this: dim ds as dataset = HttpContext.Current.Session("CustDataSet") But I get an exception if this variable in the current session hasn't been set yet so I need to test it. I tried: If HttpContext.Current.Session("CustDataSet") = nothing then HttpContext.Current.Session("CustDataSet") = GetCustDataSet()
2
1891
by: midgetgem | last post by:
I'm storing a DataTable in a session object and call a seperate class with a method in it to work with. How do I access the session from this class? I was using HttpContext.Current.Session, but that isn't the same session (has a different session ID). Could I pass in the session as a reference and if so, how?
2
1075
by: Calvin KD | last post by:
Hi everyone, I'm in the process of converting all our apps Session variables (Session("something") = "something else"). I have a few values which I'd like to store in memory (per session). These values may or may not be frequently changed during the course of the session. Because of the possibility of the web app being shared across multiple processors (servers), the Session("") can lose its value, therefore I'd like to store it somewhere...
3
2975
by: goelajay | last post by:
I have a web service where I am using System.Web.HttpContext.Current.Session. If I post an xmlrequest using an aspx page, I can referrence the Session value, but If I am posting it from say a vbs file, I cannot see the Session. What am I missing? The class which has has this code has a reference to the System.web and the web.config file in the application has the Session support turned on.
8
996
by: eric | last post by:
I have a 2.0 asp.net project. In a class contained within a seperate project, I am trying to reference HttpContext.Current.Session but Session is always null. I've tried implementing IRequiresSessionState but it does not seem to matter. For a test I created a small solution consisting of a web project and a seperate project to hold a test class. In the test class I reference HttpContext.Current.Session and it works fine with or without...
14
29486
by: R.A.M. | last post by:
Hello, I have created ASP.NET project in which I have a file Admin.cs. It contains static class Admin with some methods and properties. The problem is that in property get a reference HttpContext.Current.Session is null, although for instance HttpContext.Current.Application or HttpContext.Current.Request is not null: public static class Admin {
0
9727
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
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
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
10386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10398
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7669
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...
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.