locked
Static Connection String SQLSERVER session state issue. RRS feed

  • Question

  • User718865757 posted

    Hi,

    I implemented SQLSERVER session state in my application. And in my application we are using one variable "static ConnectionString" in this we are storing our connection string value.

    when we are using Inproc session state no issues with it. But now we are getting ConnectionString null  and giving error some times (And again its working if we refresh the page). So session is not expiring but the variable "static ConnectionString" unable to get value from SQL server some times.

    Especially when we put new build (or) When we put the application idle for some time and use again.

    Can somebody help. how to resolve this.

    Thank you.

    Wednesday, July 2, 2014 9:45 AM

Answers

  • User-484054684 posted

    It depends basically on where you are setting this static variables.

    As you know, static variables will be instantiated during the first access after the application start up. Also, when the application is idle for sometime or during new build/deployment, appPool will be recycled automatically with in the configured time based on the ping enabled flag on IIS. So, it would behave as if the application is started freshly after this recycle process.

    So your scenario is same, when the application start up, the static variable is null. So, need to make sure the code where you are setting this static variable is getting executed during this.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 2, 2014 10:46 AM

All replies

  • User-484054684 posted

    It depends basically on where you are setting this static variables.

    As you know, static variables will be instantiated during the first access after the application start up. Also, when the application is idle for sometime or during new build/deployment, appPool will be recycled automatically with in the configured time based on the ping enabled flag on IIS. So, it would behave as if the application is started freshly after this recycle process.

    So your scenario is same, when the application start up, the static variable is null. So, need to make sure the code where you are setting this static variable is getting executed during this.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 2, 2014 10:46 AM
  • User718865757 posted

    Thanks Siva Krishna. To get this issue resolved I'm getting that connection string in global.asax it self.

    Monday, July 7, 2014 4:58 AM