473,396 Members | 2,087 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.

ASP.NET Session State

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
5 2184
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nhi Lam | last post by:
Hi, I understand that there are 3 modes in which I can configure the SessionStateModule. What I need is an out of process Session State store with fail over support. The "SQL Server Mode" seems...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
3
by: Mark | last post by:
Ok, I know that .net inherently does not share session data across asp.net projects, but is there any decent work around to this. We already have a big chunk of our application using the asp.net...
2
by: John A Grandy | last post by:
for high traffic public websites , what are the proven options for session-state storage & management ? is an out-of-process state-server generally preferred over a sql-server ? what are the...
1
by: Johan Nedin | last post by:
Hello! I have a problem with SQLSession state on my ASP.NET pages. SQLSession state behaves very different from InProcess session state, which I think is very bad. I can understand some of...
10
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much...
0
by: Maciek | last post by:
Hi When I set Session state mode to StateServer (IIS 6.0; windows2003; .NET 2.0) in my application, I have recived this message:...
5
by: Sean | last post by:
Problem with sessions I have created an application without concern for sessions. As it turns out I think that might be my undoing. What I have: I have an online quiz. I don’t need to know...
2
by: DC | last post by:
Hi, we are using ASP.Net 1.1 on eight servers with one session state server (the windows 2003 service). Too often we are getting the exception "Unable to make the session state request to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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.