Loosing Session Variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Billy Jacobs

    Loosing Session Variable

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

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

    dim objUserInfo as new clsUserInfo
    'Set some properties
    objUserInfo.Use rName = txtUserName.tex t.trim
    objUserInfo...

    'Add it to session.
    Session.Add("Us erInfo",objUser Info)

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

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

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

    This is very frustrating.

    Please help.

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

    Billy Jacobs.
  • Alan Pretre

    #2
    Re: Loosing Session Variable

    "Billy Jacobs" <billnospam@csa .com> wrote in message
    news:2ae1501c39 2a1$2cd91500$a6 01280a@phx.gbl. ..[color=blue]
    > I am having a problem with my session variable being set
    > to Null for no apparent reason.
    >
    > Then as I move from page to page all of the sudden it
    > randomly is null and I get a NullReferenceEr ror.
    >
    > Is it possible that it is being garbage collected? I
    > thought that all Session objects were supposed to last
    > until the Session_End method is called.[/color]

    You could check into this:



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

    -- Alan


    Comment

    • John Lewis

      #3
      Loosing Session Variable

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

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


      They wrote back the following:

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

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

      John Lewis


      [color=blue]
      >-----Original Message-----
      >I am having a problem with my session variable being set
      >to Null for no apparent reason.
      >
      >I am declaring it like the following when the user logs[/color]
      in.[color=blue]
      >
      >dim objUserInfo as new clsUserInfo
      >'Set some properties
      >objUserInfo.Us erName = txtUserName.tex t.trim
      >objUserInfo. ..
      >
      >'Add it to session.
      >Session.Add("U serInfo",objUse rInfo)
      >
      >Then as I move from page to page all of the sudden it
      >randomly is null and I get a NullReferenceEr ror.
      >
      >Is it possible that it is being garbage collected? I
      >thought that all Session objects were supposed to last
      >until the Session_End method is called.
      >
      >I know it has not been called because I can still[/color]
      navigate[color=blue]
      >to through the pages which don't use the session
      >information and my site is protected by forms
      >authentication .
      >
      >This is very frustrating.
      >
      >Please help.
      >
      >Don't respond if you don't know what you are talking[/color]
      about.[color=blue]
      >
      >Billy Jacobs.
      >.
      >[/color]

      Comment

      • BillyJacobs

        #4
        Loosing Session Variable

        I doubt it since we have a dedicated server with 512 mg
        of ram.
        [color=blue]
        >-----Original Message-----
        >I was having a similar problem on my site. I wrote the
        >following to my ISP:
        >
        >"...Assumin g that you are using the in-process session
        >state mode and not the State Server or SQL Server modes,[/color]
        I[color=blue]
        >understand that session-state data is lost only if
        >aspnet_wp.ex e or the application domain restarts. These
        >restarts commonly occur in the following circumstances:
        >1. Setting an attribute in the element of the
        >application' s Web.config file that causes a new process[/color]
        to[color=blue]
        >start when a condition is met, such as memoryLimit.
        >2. The Global.asax or Web.config file is modified.
        >3. Changes to the \Bin directory of the Web application.
        >4. Antivirus software scans and modifies the Global.asax
        >file, the Web.config file, or a file in the \Bin[/color]
        directory[color=blue]
        >of the Web application.
        >5. If you enable Web garden mode in the element of the
        >application' s Web.config file, and use in-process[/color]
        session-[color=blue]
        >state mode, random data loss can occur. Does your event
        >log file show anything regarding the conditions of[/color]
        startup?[color=blue]
        >...."
        >
        >
        >They wrote back the following:
        >
        >"...Your apppool was recycling due to a Virtual Memory
        >limit that is in place with all the sites on this[/color]
        server.[color=blue]
        >We are in the process of deciding if this limit should[/color]
        be[color=blue]
        >raised and if so, to what number. We have doubled the
        >allowable virtual memory limit for your apppool. This
        >seems to have resolved the issue..."
        >
        >This solved the problem for me. I'd be interested if it
        >solves the problem for you.
        >
        >John Lewis
        >
        >
        >[color=green]
        >>-----Original Message-----
        >>I am having a problem with my session variable being[/color][/color]
        set[color=blue][color=green]
        >>to Null for no apparent reason.
        >>
        >>I am declaring it like the following when the user logs[/color]
        >in.[color=green]
        >>
        >>dim objUserInfo as new clsUserInfo
        >>'Set some properties
        >>objUserInfo.U serName = txtUserName.tex t.trim
        >>objUserInfo.. .
        >>
        >>'Add it to session.
        >>Session.Add(" UserInfo",objUs erInfo)
        >>
        >>Then as I move from page to page all of the sudden it
        >>randomly is null and I get a NullReferenceEr ror.
        >>
        >>Is it possible that it is being garbage collected? I
        >>thought that all Session objects were supposed to last
        >>until the Session_End method is called.
        >>
        >>I know it has not been called because I can still[/color]
        >navigate[color=green]
        >>to through the pages which don't use the session
        >>information and my site is protected by forms
        >>authenticatio n.
        >>
        >>This is very frustrating.
        >>
        >>Please help.
        >>
        >>Don't respond if you don't know what you are talking[/color]
        >about.[color=green]
        >>
        >>Billy Jacobs.
        >>.
        >>[/color]
        >.
        >[/color]

        Comment

        • Tian Min Huang

          #5
          RE: Loosing Session Variable

          Hello Billy,

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

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

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

          PRB: Session Variables Are Lost Intermittently in ASP.NET Applications
          Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.


          PRB: Session Variables Are Lost If You Use FRAMESET in Internet Explorer 6.0
          Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.


          PRB: Session State Is Lost in Web Farm If You Use SqlServer or StateServer
          Session Mode
          Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.


          INFO: Do Not Store STA Objects in Session or Application
          Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.


          PRB: Storing STA COM Component in Session Locks Session Down to Single
          Thread
          Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.


          FIX: Severe Performance Issues When You Bind Session State to Threads in
          ASPCompat Mode
          Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.


          IIS 6.0 Session State May Be Lost If You Use Web Gardens with ASP
          Applications
          Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.


          PRB: Session Data Is Lost When You Use ASP.NET InProc Session State Mode
          Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.


          BUG: Session ID Is Lost When You Close a Browser Window
          Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.


          I look forward to your result.

          Have a nice day!

          Regards,

          HuangTM
          Microsoft Online Partner Support
          MCSE/MCSD

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

          Comment

          • billnospam@csa.com

            #6
            RE: Loosing Session Variable

            1. Not the client. Happens on multiple machines.
            2. Not a timeout. I am using forms authentication and can
            still access other parts of the web that do not use the
            Session variable.
            3. Using the following:
            <sessionState
            mode="InProc"
            stateConnection String="tcpip=1 27.0.0.1:42424"
            sqlConnectionSt ring="data
            source=127.0.0. 1;user id=sa;password= "
            cookieless="fal se"
            timeout="20"
            />
            4. MCafee (will dispable and see if this helps)
            5. Dedicated Server. (No web farm)
            [color=blue]
            >-----Original Message-----
            >Hello Billy,
            >
            >Thanks for your post. As I understand, the problem you[/color]
            are facing session[color=blue]
            >lost problem in an ASP .NET application. Please correct[/color]
            me if there is any[color=blue]
            >misunderstandi ng. Based on my experience and research,[/color]
            there are a number[color=blue]
            >of possibilities that session will be lost:
            >
            >1. Client related.
            >2. Sever application related (for example, timeout).
            >3. Session management problem (inproc, state server, sql[/color]
            server problem).[color=blue]
            >4. Some anti-virus application might also affect this.
            >5. Web form or web garden related.
            >
            >The following KB articles describs the detailed[/color]
            information on session[color=blue]
            >lost. Please check them on your side:
            >
            >PRB: Session Variables Are Lost Intermittently in ASP.NET[/color]
            Applications[color=blue]
            >http://support.microsoft.com/?id=316148
            >
            >PRB: Session Variables Are Lost If You Use FRAMESET in[/color]
            Internet Explorer 6.0[color=blue]
            >http://support.microsoft.com/?id=323752
            >
            >PRB: Session State Is Lost in Web Farm If You Use[/color]
            SqlServer or StateServer[color=blue]
            >Session Mode
            >http://support.microsoft.com/?id=325056
            >
            >INFO: Do Not Store STA Objects in Session or Application
            >http://support.microsoft.com/?id=243543
            >
            >PRB: Storing STA COM Component in Session Locks Session[/color]
            Down to Single[color=blue]
            >Thread
            >http://support.microsoft.com/?id=243815
            >
            >FIX: Severe Performance Issues When You Bind Session[/color]
            State to Threads in[color=blue]
            >ASPCompat Mode
            >http://support.microsoft.com/?id=817005
            >
            >IIS 6.0 Session State May Be Lost If You Use Web Gardens[/color]
            with ASP[color=blue]
            >Applications
            >http://support.microsoft.com/?id=822171
            >
            >PRB: Session Data Is Lost When You Use ASP.NET InProc[/color]
            Session State Mode[color=blue]
            >http://support.microsoft.com/?id=324772
            >
            >BUG: Session ID Is Lost When You Close a Browser Window
            >http://support.microsoft.com/?id=311072
            >
            >I look forward to your result.
            >
            >Have a nice day!
            >
            >Regards,
            >
            >HuangTM
            >Microsoft Online Partner Support
            >MCSE/MCSD
            >
            >Get Secure! -- www.microsoft.com/security
            >This posting is provided "as is" with no warranties and[/color]
            confers no rights.[color=blue]
            >
            >.
            >[/color]

            Comment

            • Tian Min Huang

              #7
              RE: Loosing Session Variable

              Hello Billy,

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

              Have a nice day!

              Regards,

              HuangTM
              Microsoft Online Partner Support
              MCSE/MCSD

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

              Comment

              • Billy Jacobs

                #8
                RE: Loosing Session Variable

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

                Thanks,

                Billy Jacobs[color=blue]
                >-----Original Message-----
                >Hello Billy,
                >
                >Thanks for your post. As I understand, the problem you[/color]
                are facing session[color=blue]
                >lost problem in an ASP .NET application. Please correct[/color]
                me if there is any[color=blue]
                >misunderstandi ng. Based on my experience and research,[/color]
                there are a number[color=blue]
                >of possibilities that session will be lost:
                >
                >1. Client related.
                >2. Sever application related (for example, timeout).
                >3. Session management problem (inproc, state server, sql[/color]
                server problem).[color=blue]
                >4. Some anti-virus application might also affect this.
                >5. Web form or web garden related.
                >
                >The following KB articles describs the detailed[/color]
                information on session[color=blue]
                >lost. Please check them on your side:
                >
                >PRB: Session Variables Are Lost Intermittently in ASP.NET[/color]
                Applications[color=blue]
                >http://support.microsoft.com/?id=316148
                >
                >PRB: Session Variables Are Lost If You Use FRAMESET in[/color]
                Internet Explorer 6.0[color=blue]
                >http://support.microsoft.com/?id=323752
                >
                >PRB: Session State Is Lost in Web Farm If You Use[/color]
                SqlServer or StateServer[color=blue]
                >Session Mode
                >http://support.microsoft.com/?id=325056
                >
                >INFO: Do Not Store STA Objects in Session or Application
                >http://support.microsoft.com/?id=243543
                >
                >PRB: Storing STA COM Component in Session Locks Session[/color]
                Down to Single[color=blue]
                >Thread
                >http://support.microsoft.com/?id=243815
                >
                >FIX: Severe Performance Issues When You Bind Session[/color]
                State to Threads in[color=blue]
                >ASPCompat Mode
                >http://support.microsoft.com/?id=817005
                >
                >IIS 6.0 Session State May Be Lost If You Use Web Gardens[/color]
                with ASP[color=blue]
                >Applications
                >http://support.microsoft.com/?id=822171
                >
                >PRB: Session Data Is Lost When You Use ASP.NET InProc[/color]
                Session State Mode[color=blue]
                >http://support.microsoft.com/?id=324772
                >
                >BUG: Session ID Is Lost When You Close a Browser Window
                >http://support.microsoft.com/?id=311072
                >
                >I look forward to your result.
                >
                >Have a nice day!
                >
                >Regards,
                >
                >HuangTM
                >Microsoft Online Partner Support
                >MCSE/MCSD
                >
                >Get Secure! -- www.microsoft.com/security
                >This posting is provided "as is" with no warranties and[/color]
                confers no rights.[color=blue]
                >
                >.
                >[/color]

                Comment

                Working...