473,396 Members | 1,998 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,396 software developers and data experts.

HttpContext.Current.Session is throwing exception(Object reference not set to an inst

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

If HttpContext.Current.Session("Username") IsNot Nothing then
' Statements to be executed
End If
Catch ex As Exception
'Log to db
End Try

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

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

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

Similar topics

2
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...
2
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,...
2
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...
3
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...
8
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...
14
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...

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.