473,508 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session timeout in ASP.NET 2.0

hi,
I am storing some values in Session object. I am accessing these values
as Session["var"]. However there are times when i get error "Object
reference not set". This is because session has timed out and i try to
access some value stored in this object. How can I avoid this? Isnt
there any way in ASP.NEt 2.0 where before accessing any value, i check
if session exists or not? soemthing like "Session.IsExists". OR what
are the other ways of solving this problem.

Thanks
Tirath

Oct 24 '06 #1
5 4812
<ti**********@rediffmail.comwrote in message
news:11*********************@m7g2000cwm.googlegrou ps.com...
I am storing some values in Session object. I am accessing these values
as Session["var"]. However there are times when i get error "Object
reference not set". This is because session has timed out and i try to
access some value stored in this object. How can I avoid this? Isnt
there any way in ASP.NEt 2.0 where before accessing any value, i check
if session exists or not? soemthing like "Session.IsExists". OR what
are the other ways of solving this problem.
if (Session.IsNewSession)
{
// do something...
}
Oct 24 '06 #2
In addition to what Mark said, you can also check if Session["var"] == null,
to see if there is anything actually in the session variable.
<ti**********@rediffmail.comwrote in message
news:11*********************@m7g2000cwm.googlegrou ps.com...
hi,
I am storing some values in Session object. I am accessing these values
as Session["var"]. However there are times when i get error "Object
reference not set". This is because session has timed out and i try to
access some value stored in this object. How can I avoid this? Isnt
there any way in ASP.NEt 2.0 where before accessing any value, i check
if session exists or not? soemthing like "Session.IsExists". OR what
are the other ways of solving this problem.

Thanks
Tirath

Oct 24 '06 #3
While i hate sessions.. this is a good thing to know :)

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:%2***************@TK2MSFTNGP02.phx.gbl...
<ti**********@rediffmail.comwrote in message
news:11*********************@m7g2000cwm.googlegrou ps.com...
>I am storing some values in Session object. I am accessing these values
as Session["var"]. However there are times when i get error "Object
reference not set". This is because session has timed out and i try to
access some value stored in this object. How can I avoid this? Isnt
there any way in ASP.NEt 2.0 where before accessing any value, i check
if session exists or not? soemthing like "Session.IsExists". OR what
are the other ways of solving this problem.

if (Session.IsNewSession)
{
// do something...
}

Oct 25 '06 #4
"Edwin Knoppert" <ne**@hellobasic.comwrote in message
news:45**********************@text.nova.planet.nl. ..
While i hate sessions..
What a strange comment...Why on earth do you "hate" sessions...?
Oct 25 '06 #5
Oh.. just a poor statement i made :)
I 'prefer' not to use sessionvars except for passing a var from one page to
another, iow i don't remain depending on the var for longer period of time.

okidoki?
"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:%2******************@TK2MSFTNGP05.phx.gbl...
"Edwin Knoppert" <ne**@hellobasic.comwrote in message
news:45**********************@text.nova.planet.nl. ..
>While i hate sessions..

What a strange comment...Why on earth do you "hate" sessions...?

Oct 25 '06 #6

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

Similar topics

12
43154
by: Geigho | last post by:
Setting session timeout in web.config file does not seem to have any effect. Any explanation or suggestion will be appreciated.
4
15445
by: DavidS | last post by:
First: There are several ways to confuse one regarding session timeout. (1) web.config - <sessionState timeout="20"> (2) IIS Manager | Internet Information Services | ServerNode | Default Web Site...
8
7290
by: Joe Abou Jaoude | last post by:
hi, I have a web app with forms authentication and a timeout session of 20 mins for security reasons. I recently added a feature that allows users (if they want to) to automatically log in...
11
2986
by: Vishal | last post by:
Hello, can anybody tell me how I can extend the session expiry time? Is it done via code or via IIS? Sorry I am new and dont know about this.
5
2072
by: Just D. | last post by:
Do we have any access to the Session object from a different Session? The idea is to save Session of a current user and then if he logs in again then return the Session back. It's not a problem to...
8
5469
by: bdeviled | last post by:
I am deploying to a web environment that uses load balancing and to insure that sessions persist across servers, the environment uses SQL to manage sessions. The machine.config file determines how...
17
5176
by: jensen bredal | last post by:
Hello, i'm struggling with a somehow badly understood session scenario. I provide acces to my pages based on form authentication using Session cookies. Som of my pages are supposed to be...
4
9413
by: UJ | last post by:
I have a page where the user can upload a video file. As you can guess, this may take a while. Is there a way I can change the session timeout for just this one page? I would also want to change...
25
6033
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
I tried: <sessionState timeout="1"> </sessionState> bounced IIS, and after 1 minute still had a session. ??? -- thanks - dave
6
3752
by: ChrisAtWokingham | last post by:
I have been struggling with unexpected error messages on an ASP.NET system, using SQL and C#. The application draws organisation charts, based on data stored in the SQL database. Some of the chart...
0
7114
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
7321
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,...
1
7034
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
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5045
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
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...

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.