ASP.NET Session State

Discussion in 'ASP .Net' started by ASP.Confused, Jul 20, 2004.

  1. ASP.Confused

    ASP.Confused Guest

    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
     
    ASP.Confused, Jul 20, 2004
    #1
    1. Advertising

  2. 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


    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: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
    >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.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, 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
    >
    >
    >
     
    Jim Cheshire [MSFT], Jul 20, 2004
    #2
    1. Advertising

  3. ASP.Confused

    ASP.Confused Guest

    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]" <> wrote in message
    news:z1%...
    > 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
    >
    >
    > 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: <>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > >NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
    > >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.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, 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
    > >
    > >
    > >

    >
     
    ASP.Confused, Jul 20, 2004
    #3
  4. 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


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

    --------------------
    >From: "ASP.Confused" <anonymous@>
    >References: <>

    <z1#>
    >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: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
    >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.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]" <> wrote in message
    >news:z1%...
    >> 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
    >>
    >>
    >> 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: <>
    >> >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >> >NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
    >> >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.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, 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
    >> >
    >> >
    >> >

    >>

    >
    >
    >
     
    Jim Cheshire [MSFT], Jul 20, 2004
    #4
  5. ASP.Confused

    ASP.Confused Guest

    Thanks for your help!!!

    Sincerely,
    ASP.Confused


    "Jim Cheshire [MSFT]" <> wrote in message
    news:eek:O$...
    > 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
    >
    >
    > This post is provided "AS-IS" with no warranties and confers no rights.
    >
    > --------------------
    > >From: "ASP.Confused" <anonymous@>
    > >References: <>

    > <z1#>
    > >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: <>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > >NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
    > >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.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]" <> wrote in message
    > >news:z1%...
    > >> 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
    > >>
    > >>
    > >> 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: <>
    > >> >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > >> >NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
    > >> >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.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,

    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
    > >> >
    > >> >
    > >> >
    > >>

    > >
    > >
    > >

    >
     
    ASP.Confused, Jul 20, 2004
    #5
  6. You're welcome!

    Jim Cheshire [MSFT]
    MCP+I, MCSE, MCSD, MCDBA
    Microsoft Developer Support


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


    --------------------
    >From: "ASP.Confused" <anonymous@>
    >References: <>

    <z1#>
    <>
    <oO$>
    >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: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
    >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.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]" <> wrote in message
    >news:eek:O$...
    >> 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
    >>
    >>
    >> This post is provided "AS-IS" with no warranties and confers no rights.
    >>
    >> --------------------
    >> >From: "ASP.Confused" <anonymous@>
    >> >References: <>

    >> <z1#>
    >> >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: <>
    >> >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >> >NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
    >> >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.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]" <> wrote in message
    >> >news:z1%...
    >> >> 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
    >> >>
    >> >>
    >> >> 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: <>
    >> >> >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >> >> >NNTP-Posting-Host: wesout.firstam.com 65.216.70.62
    >> >> >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.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,

    >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
    >> >> >
    >> >> >
    >> >> >
    >> >>
    >> >
    >> >
    >> >

    >>

    >
    >
    >
     
    Jim Cheshire [MSFT], Jul 20, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shamanthakamani
    Replies:
    1
    Views:
    3,523
    Natty Gur
    Nov 20, 2003
  2. Jeff Smythe
    Replies:
    3
    Views:
    1,289
    Jeff Smythe
    Jan 2, 2004
  3. Not Liking Dot Net Today
    Replies:
    0
    Views:
    641
    Not Liking Dot Net Today
    Apr 21, 2004
  4. jnickfl1
    Replies:
    0
    Views:
    608
    jnickfl1
    Sep 18, 2006
  5. archana
    Replies:
    0
    Views:
    355
    archana
    Mar 13, 2007
Loading...

Share This Page