Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ASP.NET Session State

ASP.NET Session State

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-net
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Socheat Net
    wrote on last edited by
    #1

    Hi, I have problem with my web site, when user sign in i use the session to store username and password, but it early to expire. Sometimes 1 or 2 mns. I have put Session in web.config already Please help me

    Socheat

    C 1 Reply Last reply
    0
    • S Socheat Net

      Hi, I have problem with my web site, when user sign in i use the session to store username and password, but it early to expire. Sometimes 1 or 2 mns. I have put Session in web.config already Please help me

      Socheat

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      If your session is set to the default of 20 minutes then there must be some other cause. If your session is stored as "InProc" (In Process) then it can be damaged by a number of things. The App Pool being recycled (becuase it is now in a different process). IIS being reset. You have a web garden or web farm. Anything that means that the new web request is handled somehow by a different process to the previous request. However, if you are doing this in Visual Studio and stopping and starting debugging then this is only natural and to be expected.

      * Developer Day Scotland 2 - Free community conference * The Blog of Colin Angus Mackay


      Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

      S 1 Reply Last reply
      0
      • C Colin Angus Mackay

        If your session is set to the default of 20 minutes then there must be some other cause. If your session is stored as "InProc" (In Process) then it can be damaged by a number of things. The App Pool being recycled (becuase it is now in a different process). IIS being reset. You have a web garden or web farm. Anything that means that the new web request is handled somehow by a different process to the previous request. However, if you are doing this in Visual Studio and stopping and starting debugging then this is only natural and to be expected.

        * Developer Day Scotland 2 - Free community conference * The Blog of Colin Angus Mackay


        Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

        S Offline
        S Offline
        Socheat Net
        wrote on last edited by
        #3

        Yes, I used "InProc" in web.config I developed in Visual Studio in my local, it work normally, but when upload it to the server it work not good because the session always expire. So anyway that can do?

        Socheat

        N C 2 Replies Last reply
        0
        • S Socheat Net

          Yes, I used "InProc" in web.config I developed in Visual Studio in my local, it work normally, but when upload it to the server it work not good because the session always expire. So anyway that can do?

          Socheat

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Socheat.Net wrote:

          So anyway that can do?

          Just check ASP.NET process is recycling frequently? I believe it gives some entries to EventViewer when it restarts. If it is recyling frequently, you need to find why it is doing so and solve it.

          Navaneeth How to use google | Ask smart questions

          C 1 Reply Last reply
          0
          • S Socheat Net

            Yes, I used "InProc" in web.config I developed in Visual Studio in my local, it work normally, but when upload it to the server it work not good because the session always expire. So anyway that can do?

            Socheat

            C Offline
            C Offline
            Colin Angus Mackay
            wrote on last edited by
            #5

            Socheat.Net wrote:

            So anyway that can do?

            You have to find out what is causing it to expire first. This means adding some additional logging to your application (I presume you already have some logging already). To start: In your Global.asax.cs/.bv file you'll have a method that handles the Application Start event. Log when ever that is called. If you notice that it is called around the same time as you lose your session then you know that your process isn't surviving long enough. So, if your process isn't surviving very long you need to find out why. If you don't get lots of log messages in that area then you'll need to move onto the next step and log something else. It is a process of trial and error with potentially many iterations.

            * Developer Day Scotland 2 - Free community conference * The Blog of Colin Angus Mackay


            Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

            S 1 Reply Last reply
            0
            • N N a v a n e e t h

              Socheat.Net wrote:

              So anyway that can do?

              Just check ASP.NET process is recycling frequently? I believe it gives some entries to EventViewer when it restarts. If it is recyling frequently, you need to find why it is doing so and solve it.

              Navaneeth How to use google | Ask smart questions

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              N a v a n e e t h wrote:

              I believe it gives some entries to EventViewer when it restarts

              I'm not sure that it does. At least not by default. I've got a web application that recycles far too often for my liking and I only see a message that I put up when the Appliation_Start method runs to say that it has processed a certain config setting that I created.

              * Developer Day Scotland 2 - Free community conference * The Blog of Colin Angus Mackay


              Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

              N 1 Reply Last reply
              0
              • C Colin Angus Mackay

                N a v a n e e t h wrote:

                I believe it gives some entries to EventViewer when it restarts

                I'm not sure that it does. At least not by default. I've got a web application that recycles far too often for my liking and I only see a message that I put up when the Appliation_Start method runs to say that it has processed a certain config setting that I created.

                * Developer Day Scotland 2 - Free community conference * The Blog of Colin Angus Mackay


                Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

                N Offline
                N Offline
                N a v a n e e t h
                wrote on last edited by
                #7

                Colin Angus Mackay wrote:

                I'm not sure that it does. At least not by default.

                Well, I was not sure. Anyway, solving this kind of problem is a pain. :)

                Navaneeth How to use google | Ask smart questions

                C 1 Reply Last reply
                0
                • N N a v a n e e t h

                  Colin Angus Mackay wrote:

                  I'm not sure that it does. At least not by default.

                  Well, I was not sure. Anyway, solving this kind of problem is a pain. :)

                  Navaneeth How to use google | Ask smart questions

                  C Offline
                  C Offline
                  Colin Angus Mackay
                  wrote on last edited by
                  #8

                  N a v a n e e t h wrote:

                  Anyway, solving this kind of problem is a pain

                  Absolutely. :sigh:

                  * Developer Day Scotland 2 - Free community conference * The Blog of Colin Angus Mackay


                  Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

                  1 Reply Last reply
                  0
                  • C Colin Angus Mackay

                    Socheat.Net wrote:

                    So anyway that can do?

                    You have to find out what is causing it to expire first. This means adding some additional logging to your application (I presume you already have some logging already). To start: In your Global.asax.cs/.bv file you'll have a method that handles the Application Start event. Log when ever that is called. If you notice that it is called around the same time as you lose your session then you know that your process isn't surviving long enough. So, if your process isn't surviving very long you need to find out why. If you don't get lots of log messages in that area then you'll need to move onto the next step and log something else. It is a process of trial and error with potentially many iterations.

                    * Developer Day Scotland 2 - Free community conference * The Blog of Colin Angus Mackay


                    Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

                    S Offline
                    S Offline
                    Socheat Net
                    wrote on last edited by
                    #9

                    Thanks. I will try my best

                    Socheat

                    A 1 Reply Last reply
                    0
                    • S Socheat Net

                      Thanks. I will try my best

                      Socheat

                      A Offline
                      A Offline
                      Abhijit Jana
                      wrote on last edited by
                      #10

                      You can do one thing. Create a separate Application Pool For Your Web Application Only. Then test the web application. Make sure you are having only one Worker process (Not a web garden).

                      cheers, Abhijit CodeProject MVP My Recent Article : Exploring Session in ASP.Net

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups