By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,536 Members | 1,504 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,536 IT Pros & Developers. It's quick & easy.

Loosing Session Variable

P: n/a
I am having a problem with my session variable being set
to Null for no apparent reason.

I am declaring it like the following when the user logs in.

dim objUserInfo as new clsUserInfo
'Set some properties
objUserInfo.UserName = txtUserName.text.trim
objUserInfo...

'Add it to session.
Session.Add("UserInfo",objUserInfo)

Then as I move from page to page all of the sudden it
randomly is null and I get a NullReferenceError.

Is it possible that it is being garbage collected? I
thought that all Session objects were supposed to last
until the Session_End method is called.

I know it has not been called because I can still navigate
to through the pages which don't use the session
information and my site is protected by forms
authentication.

This is very frustrating.

Please help.

Don't respond if you don't know what you are talking about.

Billy Jacobs.
Jul 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"Billy Jacobs" <bi********@csa.com> wrote in message
news:2a*****************************@phx.gbl...
I am having a problem with my session variable being set
to Null for no apparent reason.

Then as I move from page to page all of the sudden it
randomly is null and I get a NullReferenceError.

Is it possible that it is being garbage collected? I
thought that all Session objects were supposed to last
until the Session_End method is called.


You could check into this:

http://groups.google.com/groups?hl=e...40TK2MSFTNGP10

Also, if IIS recycles I would imagine you would lose your session state.

-- Alan
Jul 21 '05 #2

P: n/a
I was having a similar problem on my site. I wrote the
following to my ISP:

"...Assuming that you are using the in-process session
state mode and not the State Server or SQL Server modes, I
understand that session-state data is lost only if
aspnet_wp.exe or the application domain restarts. These
restarts commonly occur in the following circumstances:
1. Setting an attribute in the element of the
application's Web.config file that causes a new process to
start when a condition is met, such as memoryLimit.
2. The Global.asax or Web.config file is modified.
3. Changes to the \Bin directory of the Web application.
4. Antivirus software scans and modifies the Global.asax
file, the Web.config file, or a file in the \Bin directory
of the Web application.
5. If you enable Web garden mode in the element of the
application's Web.config file, and use in-process session-
state mode, random data loss can occur. Does your event
log file show anything regarding the conditions of startup?
...."
They wrote back the following:

"...Your apppool was recycling due to a Virtual Memory
limit that is in place with all the sites on this server.
We are in the process of deciding if this limit should be
raised and if so, to what number. We have doubled the
allowable virtual memory limit for your apppool. This
seems to have resolved the issue..."

This solved the problem for me. I'd be interested if it
solves the problem for you.

John Lewis
-----Original Message-----
I am having a problem with my session variable being set
to Null for no apparent reason.

I am declaring it like the following when the user logs in.
dim objUserInfo as new clsUserInfo
'Set some properties
objUserInfo.UserName = txtUserName.text.trim
objUserInfo...

'Add it to session.
Session.Add("UserInfo",objUserInfo)

Then as I move from page to page all of the sudden it
randomly is null and I get a NullReferenceError.

Is it possible that it is being garbage collected? I
thought that all Session objects were supposed to last
until the Session_End method is called.

I know it has not been called because I can still navigateto through the pages which don't use the session
information and my site is protected by forms
authentication.

This is very frustrating.

Please help.

Don't respond if you don't know what you are talking about.
Billy Jacobs.
.

Jul 21 '05 #3

P: n/a
I doubt it since we have a dedicated server with 512 mg
of ram.
-----Original Message-----
I was having a similar problem on my site. I wrote the
following to my ISP:

"...Assuming that you are using the in-process session
state mode and not the State Server or SQL Server modes, Iunderstand that session-state data is lost only if
aspnet_wp.exe or the application domain restarts. These
restarts commonly occur in the following circumstances:
1. Setting an attribute in the element of the
application's Web.config file that causes a new process tostart when a condition is met, such as memoryLimit.
2. The Global.asax or Web.config file is modified.
3. Changes to the \Bin directory of the Web application.
4. Antivirus software scans and modifies the Global.asax
file, the Web.config file, or a file in the \Bin directoryof the Web application.
5. If you enable Web garden mode in the element of the
application's Web.config file, and use in-process session-state mode, random data loss can occur. Does your event
log file show anything regarding the conditions of startup?...."
They wrote back the following:

"...Your apppool was recycling due to a Virtual Memory
limit that is in place with all the sites on this server.We are in the process of deciding if this limit should beraised and if so, to what number. We have doubled the
allowable virtual memory limit for your apppool. This
seems to have resolved the issue..."

This solved the problem for me. I'd be interested if it
solves the problem for you.

John Lewis
-----Original Message-----
I am having a problem with my session variable being setto Null for no apparent reason.

I am declaring it like the following when the user logs

in.

dim objUserInfo as new clsUserInfo
'Set some properties
objUserInfo.UserName = txtUserName.text.trim
objUserInfo...

'Add it to session.
Session.Add("UserInfo",objUserInfo)

Then as I move from page to page all of the sudden it
randomly is null and I get a NullReferenceError.

Is it possible that it is being garbage collected? I
thought that all Session objects were supposed to last
until the Session_End method is called.

I know it has not been called because I can still

navigate
to through the pages which don't use the session
information and my site is protected by forms
authentication.

This is very frustrating.

Please help.

Don't respond if you don't know what you are talking

about.

Billy Jacobs.
.

.

Jul 21 '05 #4

P: n/a
Hello Billy,

Thanks for your post. As I understand, the problem you are facing session
lost problem in an ASP .NET application. Please correct me if there is any
misunderstanding. Based on my experience and research, there are a number
of possibilities that session will be lost:

1. Client related.
2. Sever application related (for example, timeout).
3. Session management problem (inproc, state server, sql server problem).
4. Some anti-virus application might also affect this.
5. Web form or web garden related.

The following KB articles describs the detailed information on session
lost. Please check them on your side:

PRB: Session Variables Are Lost Intermittently in ASP.NET Applications
http://support.microsoft.com/?id=316148

PRB: Session Variables Are Lost If You Use FRAMESET in Internet Explorer 6.0
http://support.microsoft.com/?id=323752

PRB: Session State Is Lost in Web Farm If You Use SqlServer or StateServer
Session Mode
http://support.microsoft.com/?id=325056

INFO: Do Not Store STA Objects in Session or Application
http://support.microsoft.com/?id=243543

PRB: Storing STA COM Component in Session Locks Session Down to Single
Thread
http://support.microsoft.com/?id=243815

FIX: Severe Performance Issues When You Bind Session State to Threads in
ASPCompat Mode
http://support.microsoft.com/?id=817005

IIS 6.0 Session State May Be Lost If You Use Web Gardens with ASP
Applications
http://support.microsoft.com/?id=822171

PRB: Session Data Is Lost When You Use ASP.NET InProc Session State Mode
http://support.microsoft.com/?id=324772

BUG: Session ID Is Lost When You Close a Browser Window
http://support.microsoft.com/?id=311072

I look forward to your result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #5

P: n/a
1. Not the client. Happens on multiple machines.
2. Not a timeout. I am using forms authentication and can
still access other parts of the web that do not use the
Session variable.
3. Using the following:
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;user id=sa;password="
cookieless="false"
timeout="20"
/>
4. MCafee (will dispable and see if this helps)
5. Dedicated Server. (No web farm)
-----Original Message-----
Hello Billy,

Thanks for your post. As I understand, the problem you are facing sessionlost problem in an ASP .NET application. Please correct me if there is anymisunderstanding. Based on my experience and research, there are a numberof possibilities that session will be lost:

1. Client related.
2. Sever application related (for example, timeout).
3. Session management problem (inproc, state server, sql server problem).4. Some anti-virus application might also affect this.
5. Web form or web garden related.

The following KB articles describs the detailed information on sessionlost. Please check them on your side:

PRB: Session Variables Are Lost Intermittently in ASP.NET Applicationshttp://support.microsoft.com/?id=316148

PRB: Session Variables Are Lost If You Use FRAMESET in Internet Explorer 6.0http://support.microsoft.com/?id=323752

PRB: Session State Is Lost in Web Farm If You Use SqlServer or StateServerSession Mode
http://support.microsoft.com/?id=325056

INFO: Do Not Store STA Objects in Session or Application
http://support.microsoft.com/?id=243543

PRB: Storing STA COM Component in Session Locks Session Down to SingleThread
http://support.microsoft.com/?id=243815

FIX: Severe Performance Issues When You Bind Session State to Threads inASPCompat Mode
http://support.microsoft.com/?id=817005

IIS 6.0 Session State May Be Lost If You Use Web Gardens with ASPApplications
http://support.microsoft.com/?id=822171

PRB: Session Data Is Lost When You Use ASP.NET InProc Session State Modehttp://support.microsoft.com/?id=324772

BUG: Session ID Is Lost When You Close a Browser Window
http://support.microsoft.com/?id=311072

I look forward to your result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Jul 21 '05 #6

P: n/a
Hello Billy,

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #7

P: n/a
Apparently it was the virus software causing the problem.
We turned it off of our web app directory and the problem
went away.

Thanks,

Billy Jacobs
-----Original Message-----
Hello Billy,

Thanks for your post. As I understand, the problem you are facing sessionlost problem in an ASP .NET application. Please correct me if there is anymisunderstanding. Based on my experience and research, there are a numberof possibilities that session will be lost:

1. Client related.
2. Sever application related (for example, timeout).
3. Session management problem (inproc, state server, sql server problem).4. Some anti-virus application might also affect this.
5. Web form or web garden related.

The following KB articles describs the detailed information on sessionlost. Please check them on your side:

PRB: Session Variables Are Lost Intermittently in ASP.NET Applicationshttp://support.microsoft.com/?id=316148

PRB: Session Variables Are Lost If You Use FRAMESET in Internet Explorer 6.0http://support.microsoft.com/?id=323752

PRB: Session State Is Lost in Web Farm If You Use SqlServer or StateServerSession Mode
http://support.microsoft.com/?id=325056

INFO: Do Not Store STA Objects in Session or Application
http://support.microsoft.com/?id=243543

PRB: Storing STA COM Component in Session Locks Session Down to SingleThread
http://support.microsoft.com/?id=243815

FIX: Severe Performance Issues When You Bind Session State to Threads inASPCompat Mode
http://support.microsoft.com/?id=817005

IIS 6.0 Session State May Be Lost If You Use Web Gardens with ASPApplications
http://support.microsoft.com/?id=822171

PRB: Session Data Is Lost When You Use ASP.NET InProc Session State Modehttp://support.microsoft.com/?id=324772

BUG: Session ID Is Lost When You Close a Browser Window
http://support.microsoft.com/?id=311072

I look forward to your result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Jul 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.