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

ASP.NET Session State

P: n/a
As you can tell from my previous posts on this issue...I'm really confused
:-/

I have a few ASP.NET web applications on my web host's "https" server. Our
web host has a single "bin" folder for me to toss my assemblies into. We
keep loosing session state every few months.

People have told me that my app could be running out of memory, causing the
sessions to get reset. Well, if this is the case, then when I go to the
page again, wouldn't a new session be created?
For example, I have a ASP.NET script with the following code:
----------------------------------------------------------------------------
--

<%@ Page Language="vb" EnableSessionState="true" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">
<%
' In theory, if the session variable does not exist, it will create one.
' If the session variable does exist, then it displays the value.

' If the form is submitted multiple times, the value within the session
' variable should be the same thorughout all the pages.

Randomize(Timer)

if Session("test_value") is Nothing then
Session("test_value") = CStr((65535 * Rnd()) + 1)
end if

if (Session("test_value") = "") or (Session("test_value") = "0") then
Session("test_value") = (65535 * Rnd()) + 1
end if
%>

Session("test_value") = <% =Session("test_value") %><br><INPUT id=Submit1
style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 96px" type=submit
value=Submit name=Submit1>
</form>

</body>
</HTML>

----------------------------------------------------------------------------
--

When run on a standard IIS server, this works perfectly, and returns the
same number every time you hit "Submit." On my web host's server, when we
lose session states, it keeps returning a random number every time you hit
"Submit."

My web host usually has to restart the site to get sessions to come back,
but every 1 to 2 months, the errors come back again.

ANY help would be greatly appreciated. I've already tried removing all of
the .NET assemblies except for the ones vital to our site's operation, with
no success.

Sincerely,
ASP.Confused
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Confused,

First of all, you might want to reconsider the design of this page. You
are using non-procedural ASP.NET code, and you should really not do that.
When you write ASP.NET code, that code should exist within methods that are
either called explicitly or fire from events. Otherwise, you cannot
predict where the code runs in the page lifecycle. We see plenty of issues
where code runs in an unexpected way because of this.

In your example below, it would probably make more sense to place the
ASP.NET code inside of the Page_Load event.

As for your Session variable problem, this could be caused by any number of
things. Since you say that it seems to lose Session state almost
immediately, I suspect that something is causing a File Change Notification
event in Windows and that the application domain for your ASP.NET app is
restarting. This causes you to lose Session state.

I would ask your host if they are running Index Services against your site
content or whether or not they have anti-virus software scanning your
content folders. There are also Performance Monitor counters that will
capture information about application restarts. You might ask your host to
get you a counter log to see if that's the issue.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
ja******@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
From: "ASP.Confused" <anonymous@>
Subject: ASP.NET Session State
Date: Tue, 20 Jul 2004 10:19:12 -0400
Lines: 75
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <eZ*************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:248423
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

As you can tell from my previous posts on this issue...I'm really confused
:-/

I have a few ASP.NET web applications on my web host's "https" server. Our
web host has a single "bin" folder for me to toss my assemblies into. We
keep loosing session state every few months.

People have told me that my app could be running out of memory, causing the
sessions to get reset. Well, if this is the case, then when I go to the
page again, wouldn't a new session be created?
For example, I have a ASP.NET script with the following code:
--------------------------------------------------------------------------- ---

<%@ Page Language="vb" EnableSessionState="true" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">
<%
' In theory, if the session variable does not exist, it will create one. ' If the session variable does exist, then it displays the value.

' If the form is submitted multiple times, the value within the session
' variable should be the same thorughout all the pages.

Randomize(Timer)

if Session("test_value") is Nothing then
Session("test_value") = CStr((65535 * Rnd()) + 1)
end if

if (Session("test_value") = "") or (Session("test_value") = "0") then
Session("test_value") = (65535 * Rnd()) + 1
end if
%>

Session("test_value") = <% =Session("test_value") %><br><INPUT id=Submit1style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 96px" type=submit
value=Submit name=Submit1>
</form>

</body>
</HTML>

--------------------------------------------------------------------------- ---

When run on a standard IIS server, this works perfectly, and returns the
same number every time you hit "Submit." On my web host's server, when we
lose session states, it keeps returning a random number every time you hit
"Submit."

My web host usually has to restart the site to get sessions to come back,
but every 1 to 2 months, the errors come back again.

ANY help would be greatly appreciated. I've already tried removing all of
the .NET assemblies except for the ones vital to our site's operation, with
no success.

Sincerely,
ASP.Confused


Nov 18 '05 #2

P: n/a
As for my coding, I normally use compiled .NET assemblies to do my code. I
wrote the example script just to give you an example.

The web host does not do virus scanning on .NET apps, web.config or
global.asax, already checked that.

I also just noticed that the application variables aren't keeping values
either. If the application is restarting, will the performance monitor
still allow me to check for restarts within a .NET app? I have tried using
them before, but the user account on the host does not have access to it.

I am going to try to have the web host create a separate application folder
for .NET, and try isolating some of my .net apps. I'm hoping this will
help.

Now, if something is causing the File Change Notification event in Windows,
wouldn't it happen constantly, forcing my app to restart constantly? In my
original post, I noted that after my host restarts our site, the issues go
away for a month or two. I wouldn't think that it would be anything
touching the files.

Does Index Services run constantly, or periodically...because this might be
the issue.

Thank you for your help.

Sincerely,
ASP.Confused


"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:z1****************@cpmsftngxa06.phx.gbl...
Hi Confused,

First of all, you might want to reconsider the design of this page. You
are using non-procedural ASP.NET code, and you should really not do that.
When you write ASP.NET code, that code should exist within methods that are either called explicitly or fire from events. Otherwise, you cannot
predict where the code runs in the page lifecycle. We see plenty of issues where code runs in an unexpected way because of this.

In your example below, it would probably make more sense to place the
ASP.NET code inside of the Page_Load event.

As for your Session variable problem, this could be caused by any number of things. Since you say that it seems to lose Session state almost
immediately, I suspect that something is causing a File Change Notification event in Windows and that the application domain for your ASP.NET app is
restarting. This causes you to lose Session state.

I would ask your host if they are running Index Services against your site
content or whether or not they have anti-virus software scanning your
content folders. There are also Performance Monitor counters that will
capture information about application restarts. You might ask your host to get you a counter log to see if that's the issue.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
ja******@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
From: "ASP.Confused" <anonymous@>
Subject: ASP.NET Session State
Date: Tue, 20 Jul 2004 10:19:12 -0400
Lines: 75
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <eZ*************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:248423X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

As you can tell from my previous posts on this issue...I'm really confused:-/

I have a few ASP.NET web applications on my web host's "https" server. Ourweb host has a single "bin" folder for me to toss my assemblies into. We
keep loosing session state every few months.

People have told me that my app could be running out of memory, causing thesessions to get reset. Well, if this is the case, then when I go to the
page again, wouldn't a new session be created?
For example, I have a ASP.NET script with the following code:


---------------------------------------------------------------------------
-
--

<%@ Page Language="vb" EnableSessionState="true" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">
<%
' In theory, if the session variable does not exist, it will create

one.
' If the session variable does exist, then it displays the value.

' If the form is submitted multiple times, the value within the session ' variable should be the same thorughout all the pages.

Randomize(Timer)

if Session("test_value") is Nothing then
Session("test_value") = CStr((65535 * Rnd()) + 1)
end if

if (Session("test_value") = "") or (Session("test_value") = "0") then
Session("test_value") = (65535 * Rnd()) + 1
end if
%>

Session("test_value") = <% =Session("test_value") %><br><INPUT

id=Submit1
style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 96px" type=submitvalue=Submit name=Submit1>
</form>

</body>
</HTML>


---------------------------------------------------------------------------
-
--

When run on a standard IIS server, this works perfectly, and returns the
same number every time you hit "Submit." On my web host's server, when welose session states, it keeps returning a random number every time you hit"Submit."

My web host usually has to restart the site to get sessions to come back,
but every 1 to 2 months, the errors come back again.

ANY help would be greatly appreciated. I've already tried removing all ofthe .NET assemblies except for the ones vital to our site's operation, withno success.

Sincerely,
ASP.Confused

Nov 18 '05 #3

P: n/a
Anytime one of the bits is changed in your content files, Windows will send
a File Change Notification event. When that happens, the app domain will
recycle. You will lose all Application and Session variables. I can't
answer as to why it stops for a month or so after reboot. As you can
imagine there are literally thousands of different processes that could be
touching these files and causing this.

The ASP.NET v1.1.4322 object has a counter called Application Restarts.
That counter will tell you when the application has restarted.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
ja******@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
From: "ASP.Confused" <anonymous@>
References: <eZ*************@TK2MSFTNGP10.phx.gbl> <z1**************@cpmsftngxa06.phx.gbl>Subject: Re: ASP.NET Session State
Date: Tue, 20 Jul 2004 11:11:52 -0400
Lines: 181
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <uD**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:248460
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

As for my coding, I normally use compiled .NET assemblies to do my code. I
wrote the example script just to give you an example.

The web host does not do virus scanning on .NET apps, web.config or
global.asax, already checked that.

I also just noticed that the application variables aren't keeping values
either. If the application is restarting, will the performance monitor
still allow me to check for restarts within a .NET app? I have tried using
them before, but the user account on the host does not have access to it.

I am going to try to have the web host create a separate application folder
for .NET, and try isolating some of my .net apps. I'm hoping this will
help.

Now, if something is causing the File Change Notification event in Windows,
wouldn't it happen constantly, forcing my app to restart constantly? In my
original post, I noted that after my host restarts our site, the issues go
away for a month or two. I wouldn't think that it would be anything
touching the files.

Does Index Services run constantly, or periodically...because this might be
the issue.

Thank you for your help.

Sincerely,
ASP.Confused


"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:z1****************@cpmsftngxa06.phx.gbl...
Hi Confused,

First of all, you might want to reconsider the design of this page. You
are using non-procedural ASP.NET code, and you should really not do that.
When you write ASP.NET code, that code should exist within methods that

are
either called explicitly or fire from events. Otherwise, you cannot
predict where the code runs in the page lifecycle. We see plenty of

issues
where code runs in an unexpected way because of this.

In your example below, it would probably make more sense to place the
ASP.NET code inside of the Page_Load event.

As for your Session variable problem, this could be caused by any number

of
things. Since you say that it seems to lose Session state almost
immediately, I suspect that something is causing a File Change

Notification
event in Windows and that the application domain for your ASP.NET app is
restarting. This causes you to lose Session state.

I would ask your host if they are running Index Services against your site
content or whether or not they have anti-virus software scanning your
content folders. There are also Performance Monitor counters that will
capture information about application restarts. You might ask your host

to
get you a counter log to see if that's the issue.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
ja******@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
>From: "ASP.Confused" <anonymous@>
>Subject: ASP.NET Session State
>Date: Tue, 20 Jul 2004 10:19:12 -0400
>Lines: 75
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
>Message-ID: <eZ*************@TK2MSFTNGP10.phx.gbl>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
>Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
>Xref: cpmsftngxa06.phx.gblmicrosoft.public.dotnet.framework.aspnet:248423 >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>As you can tell from my previous posts on this issue...I'm reallyconfused >:-/
>
>I have a few ASP.NET web applications on my web host's "https" server.Our >web host has a single "bin" folder for me to toss my assemblies into. We >keep loosing session state every few months.
>
>People have told me that my app could be running out of memory, causingthe >sessions to get reset. Well, if this is the case, then when I go to the
>page again, wouldn't a new session be created?
>
>
>For example, I have a ASP.NET script with the following code:


-------------------------------------------------------------------------- - -
>--
>
><%@ Page Language="vb" EnableSessionState="true" %>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
><HTML>
> <HEAD>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
> <meta name=vs_defaultClientScript content="JavaScript">
> <meta name=vs_targetSchema
>content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body MS_POSITIONING="GridLayout">
>
> <form id="Form1" method="post" runat="server">
> <%
> ' In theory, if the session variable does not exist, it will create

one.
> ' If the session variable does exist, then it displays the value.
>
> ' If the form is submitted multiple times, the value within thesession > ' variable should be the same thorughout all the pages.
>
> Randomize(Timer)
>
> if Session("test_value") is Nothing then
> Session("test_value") = CStr((65535 * Rnd()) + 1)
> end if
>
> if (Session("test_value") = "") or (Session("test_value") = "0") then > Session("test_value") = (65535 * Rnd()) + 1
> end if
> %>
>
> Session("test_value") = <% =Session("test_value") %><br><INPUT

id=Submit1
>style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 96px"type=submit >value=Submit name=Submit1>
> </form>
>
> </body>
></HTML>
>


-------------------------------------------------------------------------- - -
>--
>
>When run on a standard IIS server, this works perfectly, and returns the
>same number every time you hit "Submit." On my web host's server, when

we >lose session states, it keeps returning a random number every time youhit >"Submit."
>
>My web host usually has to restart the site to get sessions to come back, >but every 1 to 2 months, the errors come back again.
>
>ANY help would be greatly appreciated. I've already tried removing allof >the .NET assemblies except for the ones vital to our site's operation,with >no success.
>
>Sincerely,
>ASP.Confused
>
>
>



Nov 18 '05 #4

P: n/a
Thanks for your help!!!

Sincerely,
ASP.Confused
"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:oO*************@cpmsftngxa06.phx.gbl...
Anytime one of the bits is changed in your content files, Windows will send a File Change Notification event. When that happens, the app domain will
recycle. You will lose all Application and Session variables. I can't
answer as to why it stops for a month or so after reboot. As you can
imagine there are literally thousands of different processes that could be
touching these files and causing this.

The ASP.NET v1.1.4322 object has a counter called Application Restarts.
That counter will tell you when the application has restarted.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
ja******@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
From: "ASP.Confused" <anonymous@>
References: <eZ*************@TK2MSFTNGP10.phx.gbl>

<z1**************@cpmsftngxa06.phx.gbl>
Subject: Re: ASP.NET Session State
Date: Tue, 20 Jul 2004 11:11:52 -0400
Lines: 181
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <uD**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:248460
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

As for my coding, I normally use compiled .NET assemblies to do my code. Iwrote the example script just to give you an example.

The web host does not do virus scanning on .NET apps, web.config or
global.asax, already checked that.

I also just noticed that the application variables aren't keeping values
either. If the application is restarting, will the performance monitor
still allow me to check for restarts within a .NET app? I have tried usingthem before, but the user account on the host does not have access to it.

I am going to try to have the web host create a separate application folderfor .NET, and try isolating some of my .net apps. I'm hoping this will
help.

Now, if something is causing the File Change Notification event in Windows,wouldn't it happen constantly, forcing my app to restart constantly? In myoriginal post, I noted that after my host restarts our site, the issues goaway for a month or two. I wouldn't think that it would be anything
touching the files.

Does Index Services run constantly, or periodically...because this might bethe issue.

Thank you for your help.

Sincerely,
ASP.Confused


"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:z1****************@cpmsftngxa06.phx.gbl...
Hi Confused,

First of all, you might want to reconsider the design of this page. You are using non-procedural ASP.NET code, and you should really not do that. When you write ASP.NET code, that code should exist within methods that

are
either called explicitly or fire from events. Otherwise, you cannot
predict where the code runs in the page lifecycle. We see plenty of

issues
where code runs in an unexpected way because of this.

In your example below, it would probably make more sense to place the
ASP.NET code inside of the Page_Load event.

As for your Session variable problem, this could be caused by any number
of
things. Since you say that it seems to lose Session state almost
immediately, I suspect that something is causing a File Change

Notification
event in Windows and that the application domain for your ASP.NET app
is restarting. This causes you to lose Session state.

I would ask your host if they are running Index Services against your

site content or whether or not they have anti-virus software scanning your
content folders. There are also Performance Monitor counters that will
capture information about application restarts. You might ask your hostto
get you a counter log to see if that's the issue.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
ja******@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
>From: "ASP.Confused" <anonymous@>
>Subject: ASP.NET Session State
>Date: Tue, 20 Jul 2004 10:19:12 -0400
>Lines: 75
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
>Message-ID: <eZ*************@TK2MSFTNGP10.phx.gbl>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
>Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
>Xref: cpmsftngxa06.phx.gbl

microsoft.public.dotnet.framework.aspnet:248423
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>As you can tell from my previous posts on this issue...I'm really

confused
>:-/
>
>I have a few ASP.NET web applications on my web host's "https" server.

Our
>web host has a single "bin" folder for me to toss my assemblies into. We >keep loosing session state every few months.
>
>People have told me that my app could be running out of memory,
causing
the
>sessions to get reset. Well, if this is the case, then when I go to
the >page again, wouldn't a new session be created?
>
>
>For example, I have a ASP.NET script with the following code:

--------------------------------------------------------------------------

- -
>--
>
><%@ Page Language="vb" EnableSessionState="true" %>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
><HTML>
> <HEAD>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
> <meta name=vs_defaultClientScript content="JavaScript">
> <meta name=vs_targetSchema
>content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body MS_POSITIONING="GridLayout">
>
> <form id="Form1" method="post" runat="server">
> <%
> ' In theory, if the session variable does not exist, it will create one.
> ' If the session variable does exist, then it displays the value.
>
> ' If the form is submitted multiple times, the value within the

session
> ' variable should be the same thorughout all the pages.
>
> Randomize(Timer)
>
> if Session("test_value") is Nothing then
> Session("test_value") = CStr((65535 * Rnd()) + 1)
> end if
>
> if (Session("test_value") = "") or (Session("test_value") = "0") then > Session("test_value") = (65535 * Rnd()) + 1
> end if
> %>
>
> Session("test_value") = <% =Session("test_value") %><br><INPUT
id=Submit1
>style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 96px"

type=submit
>value=Submit name=Submit1>
> </form>
>
> </body>
></HTML>
>
--------------------------------------------------------------------------

- -
>--
>
>When run on a standard IIS server, this works perfectly, and returns the >same number every time you hit "Submit." On my web host's server,
whenwe
>lose session states, it keeps returning a random number every time you

hit
>"Submit."
>
>My web host usually has to restart the site to get sessions to come back, >but every 1 to 2 months, the errors come back again.
>
>ANY help would be greatly appreciated. I've already tried removing

allof
>the .NET assemblies except for the ones vital to our site's operation,

with
>no success.
>
>Sincerely,
>ASP.Confused
>
>
>


Nov 18 '05 #5

P: n/a
You're welcome!

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
ja******@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.
--------------------
From: "ASP.Confused" <anonymous@>
References: <eZ*************@TK2MSFTNGP10.phx.gbl> <z1**************@cpmsftngxa06.phx.gbl>
<uD**************@TK2MSFTNGP10.phx.gbl>
<oO*************@cpmsftngxa06.phx.gbl>Subject: Re: ASP.NET Session State
Date: Tue, 20 Jul 2004 11:30:46 -0400
Lines: 256
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <uF*************@TK2MSFTNGP09.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:248469
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Thanks for your help!!!

Sincerely,
ASP.Confused
"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:oO*************@cpmsftngxa06.phx.gbl...
Anytime one of the bits is changed in your content files, Windows will

send
a File Change Notification event. When that happens, the app domain will
recycle. You will lose all Application and Session variables. I can't
answer as to why it stops for a month or so after reboot. As you can
imagine there are literally thousands of different processes that could be
touching these files and causing this.

The ASP.NET v1.1.4322 object has a counter called Application Restarts.
That counter will tell you when the application has restarted.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
ja******@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
>From: "ASP.Confused" <anonymous@>
>References: <eZ*************@TK2MSFTNGP10.phx.gbl>

<z1**************@cpmsftngxa06.phx.gbl>
>Subject: Re: ASP.NET Session State
>Date: Tue, 20 Jul 2004 11:11:52 -0400
>Lines: 181
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
>Message-ID: <uD**************@TK2MSFTNGP10.phx.gbl>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
>Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
>Xref: cpmsftngxa06.phx.gblmicrosoft.public.dotnet.framework.aspnet:248460 >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>As for my coding, I normally use compiled .NET assemblies to do my code.I >wrote the example script just to give you an example.
>
>The web host does not do virus scanning on .NET apps, web.config or
>global.asax, already checked that.
>
>I also just noticed that the application variables aren't keeping values
>either. If the application is restarting, will the performance monitor
>still allow me to check for restarts within a .NET app? I have triedusing >them before, but the user account on the host does not have access to it. >
>I am going to try to have the web host create a separate applicationfolder >for .NET, and try isolating some of my .net apps. I'm hoping this will
>help.
>
>Now, if something is causing the File Change Notification event inWindows, >wouldn't it happen constantly, forcing my app to restart constantly? Inmy >original post, I noted that after my host restarts our site, the issuesgo >away for a month or two. I wouldn't think that it would be anything
>touching the files.
>
>Does Index Services run constantly, or periodically...because this mightbe >the issue.
>
>Thank you for your help.
>
>Sincerely,
>ASP.Confused
>
>
>
>
>"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
>news:z1****************@cpmsftngxa06.phx.gbl...
>> Hi Confused,
>>
>> First of all, you might want to reconsider the design of this page.You >> are using non-procedural ASP.NET code, and you should really not dothat. >> When you write ASP.NET code, that code should exist within methods that >are
>> either called explicitly or fire from events. Otherwise, you cannot
>> predict where the code runs in the page lifecycle. We see plenty of
>issues
>> where code runs in an unexpected way because of this.
>>
>> In your example below, it would probably make more sense to place the
>> ASP.NET code inside of the Page_Load event.
>>
>> As for your Session variable problem, this could be caused by anynumber >of
>> things. Since you say that it seems to lose Session state almost
>> immediately, I suspect that something is causing a File Change
>Notification
>> event in Windows and that the application domain for your ASP.NET appis >> restarting. This causes you to lose Session state.
>>
>> I would ask your host if they are running Index Services against your

site
>> content or whether or not they have anti-virus software scanning your
>> content folders. There are also Performance Monitor counters that will >> capture information about application restarts. You might ask yourhost >to
>> get you a counter log to see if that's the issue.
>>
>> Jim Cheshire [MSFT]
>> MCP+I, MCSE, MCSD, MCDBA
>> Microsoft Developer Support
>> ja******@online.microsoft.com
>>
>> This post is provided "AS-IS" with no warranties and confers no rights. >>
>> --------------------
>> >From: "ASP.Confused" <anonymous@>
>> >Subject: ASP.NET Session State
>> >Date: Tue, 20 Jul 2004 10:19:12 -0400
>> >Lines: 75
>> >X-Priority: 3
>> >X-MSMail-Priority: Normal
>> >X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
>> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
>> >Message-ID: <eZ*************@TK2MSFTNGP10.phx.gbl>
>> >Newsgroups: microsoft.public.dotnet.framework.aspnet
>> >NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
>> >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
>> >Xref: cpmsftngxa06.phx.gbl
>microsoft.public.dotnet.framework.aspnet:248423
>> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>> >
>> >As you can tell from my previous posts on this issue...I'm really
>confused
>> >:-/
>> >
>> >I have a few ASP.NET web applications on my web host's "https" server. >Our
>> >web host has a single "bin" folder for me to toss my assemblies into.

We
>> >keep loosing session state every few months.
>> >
>> >People have told me that my app could be running out of memory,causing >the
>> >sessions to get reset. Well, if this is the case, then when I go tothe >> >page again, wouldn't a new session be created?
>> >
>> >
>> >For example, I have a ASP.NET script with the following code:
>>

------------------------------------------------------------------------- - -
>> -
>> >--
>> >
>> ><%@ Page Language="vb" EnableSessionState="true" %>
>> ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>> ><HTML>
>> > <HEAD>
>> > <title>WebForm1</title>
>> > <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
>> > <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
>> > <meta name=vs_defaultClientScript content="JavaScript">
>> > <meta name=vs_targetSchema
>> >content="http://schemas.microsoft.com/intellisense/ie5">
>> > </HEAD>
>> > <body MS_POSITIONING="GridLayout">
>> >
>> > <form id="Form1" method="post" runat="server">
>> > <%
>> > ' In theory, if the session variable does not exist, it willcreate >> one.
>> > ' If the session variable does exist, then it displays the value.
>> >
>> > ' If the form is submitted multiple times, the value within the
>session
>> > ' variable should be the same thorughout all the pages.
>> >
>> > Randomize(Timer)
>> >
>> > if Session("test_value") is Nothing then
>> > Session("test_value") = CStr((65535 * Rnd()) + 1)
>> > end if
>> >
>> > if (Session("test_value") = "") or (Session("test_value") = "0")

then
>> > Session("test_value") = (65535 * Rnd()) + 1
>> > end if
>> > %>
>> >
>> > Session("test_value") = <% =Session("test_value") %><br><INPUT
>> id=Submit1
>> >style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 96px"
>type=submit
>> >value=Submit name=Submit1>
>> > </form>
>> >
>> > </body>
>> ></HTML>
>> >
>>

-------------------------------------------------------------------------
-
-
>> -
>> >--
>> >
>> >When run on a standard IIS server, this works perfectly, and returns

the >> >same number every time you hit "Submit." On my web host's server,when >we
>> >lose session states, it keeps returning a random number every time
you >hit
>> >"Submit."
>> >
>> >My web host usually has to restart the site to get sessions to come

back,
>> >but every 1 to 2 months, the errors come back again.
>> >
>> >ANY help would be greatly appreciated. I've already tried removing

all >of
>> >the .NET assemblies except for the ones vital to our site's operation, >with
>> >no success.
>> >
>> >Sincerely,
>> >ASP.Confused
>> >
>> >
>> >
>>
>
>
>



Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.