473,387 Members | 2,436 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,387 software developers and data experts.

Session problem

hi,
I am anand.I used session state object in some pages in my application ex
Session("UserId").

some times applications displayed the following error

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
pos.TopBanner.Page_Load(Object sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +772
how to rectify the error?
regards
anand
Sep 22 '06 #1
2 3295
hi,
I am anand.I used session state object in some pages in my application ex
Session("UserId").

some times applications displayed the following error

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an
object.]
pos.TopBanner.Page_Load(Object sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +772

how to rectify the error?
regards
anand
You didn't specify the source where the error occurred, so it is not
clear to me that it has anything to do with that Session object. But
that /is/ possible.

The error means that you try to use some reference as if it is pointing
to a real instance of a class, but (at this time) it isn't pointing
anywhere (it's null).

Your crash *can* occur in a place where you try to use that session
object, if that object doesn't exist (yet). Say you are trying to use
that object before the person has logged in (causing that userid to be
set).

Solutions:
1) carefully review your application: are you trying to use that
session object before it is filled?
2) check that it really exists before using it. In C#:
if (Session["userid"] != null) ...

Hans Kesting
Sep 22 '06 #2
Hi, check if the session is not null before working with it.
if session("userid") isnot nothing then
.....
end if

Have you checked your session timeout value?.
---------------------------
Thanks,
Ibrahim

Software Consultant - Web Development, GB
"Hans Kesting" wrote:
hi,
I am anand.I used session state object in some pages in my application ex
Session("UserId").

some times applications displayed the following error

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an
object.]
pos.TopBanner.Page_Load(Object sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +772

how to rectify the error?
regards
anand

You didn't specify the source where the error occurred, so it is not
clear to me that it has anything to do with that Session object. But
that /is/ possible.

The error means that you try to use some reference as if it is pointing
to a real instance of a class, but (at this time) it isn't pointing
anywhere (it's null).

Your crash *can* occur in a place where you try to use that session
object, if that object doesn't exist (yet). Say you are trying to use
that object before the person has logged in (causing that userid to be
set).

Solutions:
1) carefully review your application: are you trying to use that
session object before it is filled?
2) check that it really exists before using it. In C#:
if (Session["userid"] != null) ...

Hans Kesting
Sep 22 '06 #3

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

Similar topics

1
by: Jonathan Chong | last post by:
I have problem with AOL browser (IE and Netscape are OK) accessing my Web site after putting up a load balancer that will go to W1 or W2. The problem does not happen when there is only Web server...
5
by: Roman | last post by:
Hi, I've installed .net on my server and since then I'm loosing my sessions from my (old) asp. e.g.: Session("test") works on the same page, but if the page is changed the whole session is...
0
by: Marek | last post by:
Hi, I have the following session problem: I've created simple login/logout form to prevent unknown users from accessing my private web site part and It is not working on the www server. It seems...
0
by: Sabari | last post by:
Hi, In our application we face a session problem.Its kinda strange as well.We have our session timeout in web.config file to 240 minutes.It works fine in our intranet.When we moved the project to...
1
by: caldera | last post by:
Hello, We have a session problem. A dataset is put into a session and call this session value later. When we run this web page in http://localhost it works. But server has a specific name like...
4
by: alan | last post by:
Hi, i have some problem in asp.net session problem in page_load -> i have Label1.text = Session("a") in DataGrid1_sortCommand -> i have Session("a") = e.sortExpression
3
by: sri | last post by:
Hi, I have Login page (login.aspx") and after entering into inbox by giving valid userid and password the session item is userid and password. In inbox page ("inbox.aspx") i have logoff button and...
2
by: Tom | last post by:
I hope someone can help me figure out what's going on here. I've re-read the section on sessions at php.net and Googled this high and low but I haven't found anything that quite explains my...
3
by: deepsfriend4u | last post by:
Hello, i have one application in that i use session . problem is, same code and session data use work successful in Firefox but not work in Internet Explore. Thanks & Regards ...
2
by: Kong Chun Ho | last post by:
Hi all, I have a php session problem when i echo a session_id, it return nothing! <?php if(!session_start()) { exit(); }else{ ob_start(); session_start(); echo session_id(); echo SID;...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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,...
0
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...
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...

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.