By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,649 Members | 696 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,649 IT Pros & Developers. It's quick & easy.

Sessions Lost With SqlServer

P: 8
Having trouble with an application which is using SQL Server 2000 to store session state. The App is ASP.NET 2.0 on Win2003.

Occasionally all sessions are lost at once, causing the app to break.

I know there are issues with InProc sessions relating to antivirus products, directory deletes, config changes .... and had the problem InProc before, but now I'm using SQL Server it should be persistent.

If I do an IIS reset the sessions magically come back. When InProc before they were lost permenantly.

Any suggestions ?
Apr 19 '07 #1
Share this Question
Share on Google+
10 Replies


P: 8
By the way I am using a web garden
Apr 19 '07 #2

Frinavale
Expert Mod 5K+
P: 9,731
By the way I am using a web garden
I am not familiar with web gardens so I took some time to look up why you might be encountering these issues.

I found a very informative conversation posted and found the following quite interesting. It explains why you would be having problems with inProc Session storage while using a web garden:
If you have code that relies on sessions, and you enable the web garden feature (set max processes to > 1 for an app pool), you will experience this "curious" "intermittent" loss of sessions (or "unexplainable logouts").

The problem isn't work process recycling, nor even application domain restarts (other problems that can kill sessions or force logouts). Instead, it's just that the web garden feature can cause your requests to eventually be directed to a new worker process where the session you had is not existing.

Bottom line: if using sessions and you enable web gardens, you had better enable StateServer or SQLServer for session management.
Since you're using SQLServer to store your session state you shouldn't be experiencing these problems.

Have you made sure that your Application Pool settings are correct?
Have you determined the scenario when the Sessions are lost?

-Frinny
Apr 20 '07 #3

P: 8
Hi, yes there are a number of problems with In Proc. I have moved to SQL Server sessions to avoid these but still lose all sessions at once a couple of times a day. When using In Proc they were gone for good, but with SQL Server 200 backed sessions they come back with an IIS reset.
Apr 22 '07 #4

P: 8
My full web.config is below incase that will help:

Part 1
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?> 
  2. <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  3.     <configSections>
  4.         <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
  5.             <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
  6.                 <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
  7.                 <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
  8.                     <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
  9.                     <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
  10.                     <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
  11.                 </sectionGroup>
  12.             </sectionGroup>
  13.         </sectionGroup>
  14.         <section name="XXXXX.Data" type="XXXXX.Data.Bases.NetTiersServiceSection, XXXXX.Data" allowDefinition="MachineToApplication" restartOnExternalChanges="true"/>
  15.         <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  16.     </configSections>
  17.     <XXXXX.Data defaultProvider="SqlNetTiersProvider">
  18.         <providers>
  19.             <!--
  20.                 *** SqlClient Provider ***
  21.                     connectionStringName: sqlclient connection string to the db
  22.                     useStoredProcedure: if true, indicates that we use the stored procedures, otherwise, we use parametrized queries that are embedded.
  23.             -->
  24.             <add name="SqlNetTiersProvider" type="XXXXX.Data.SqlClient.SqlNetTiersProvider, XXXXX.Data.SqlClient" connectionStringName="LocalSqlServer" providerInvariantName="System.Data.SqlClient" entityFactoryType="XXXXX.Entities.EntityFactory" useEntityFactory="true" enableEntityTracking="true" enableMethodAuthorization="false" useStoredProcedure="false"/>
  25.             <!-- 
  26.                 *** WebserviceClient Provider ***
  27.                 The url parameter indicates the webservices url (ex: http://localhost/XXXXX/XXXXXServices.aspx)
  28.                 <add 
  29.                     name="WsNetTiersProvider" 
  30.                     type="XXXXX.Data.WebServiceClient.WsNetTiersProvider, XXXXX.Data.WebServiceClient"
  31.                     url="/XXXXXServices.asmx" />
  32.             -->
  33.         </providers>
  34.     </XXXXX.Data>
  35.     <enterpriseLibrary.ConfigurationSource selectedSource="File Configuration Source">
  36.         <sources>
  37.             <add name="File Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" filePath="entlib.config"/>
  38.         </sources>
  39.     </enterpriseLibrary.ConfigurationSource>
  40.     <appSettings/>
  41.     <connectionStrings>
  42.   <clear />
  43.   <add name="LocalSqlServer" connectionString="data source=Bintang\Bintang2000;Initial Catalog=XXXXX2;user id=XXXXXAdmin;password=password;persist security info=true;packet size=4096"
  44.    providerName="System.Data.SqlClient" />
  45.  </connectionStrings>
  46.     <system.web>
  47.         <!-- SessionState -->
  48.         <customErrors mode="Off" />
  49.   <sessionState sqlConnectionString="data source=YYYYYServer; user id=XXXXXAdmin;password=$car1ito!!;persist security info=true;packet size=4096" />
  50.         <roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
  51.    <providers>
  52.     <add connectionStringName="LocalSqlServer" applicationName="/"
  53.      name="CustomizedRoleProvider" type="XXXXXRoleProvider" />
  54.    </providers>
  55.   </roleManager>
  56.         <membership defaultProvider="AspNetSqlProvider">
  57.    <providers>
  58.     <clear />
  59.     <add connectionStringName="LocalSqlServer" enablePasswordReset="true"
  60.      requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
  61.      passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5"
  62.      minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
  63.      passwordStrengthRegularExpression="" applicationName="/" name="AspNetSqlProvider"
  64.      type="XXXXXMembershipProvider" />
  65.    </providers>
  66.   </membership>
  67.         <pages pageBaseType="WebPageBase">
  68.             <controls>
  69.                 <add tagPrefix="ajaxToolkit" namespXXXXX="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
  70.                 <add tagPrefix="asp" namespXXXXX="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  71.                 <add tagPrefix="asp" namespXXXXX="Microsoft.Web.Preview.UI" assembly="Microsoft.Web.Preview"/>
  72.                 <add tagPrefix="asp" namespXXXXX="Microsoft.Web.Preview.UI.Controls" assembly="Microsoft.Web.Preview"/>
  73.                 <add tagPrefix="data" namespXXXXX="XXXXX.Web.Data" assembly="XXXXX.Web"/>
  74.                 <add tagPrefix="data" namespXXXXX="XXXXX.Web.UI" assembly="XXXXX.Web"/>
  75.             </controls>
  76.             <tagMapping>
  77.                 <add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Sample.Web.UI.Compatibility.CompareValidator, Validators, Version=1.0.0.0"/>
  78.                 <add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Sample.Web.UI.Compatibility.CustomValidator, Validators, Version=1.0.0.0"/>
  79.                 <add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Sample.Web.UI.Compatibility.RangeValidator, Validators, Version=1.0.0.0"/>
  80.                 <add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Sample.Web.UI.Compatibility.RegularExpressionValidator, Validators, Version=1.0.0.0"/>
  81.                 <add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Sample.Web.UI.Compatibility.RequiredFieldValidator, Validators, Version=1.0.0.0"/>
  82.                 <add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Sample.Web.UI.Compatibility.ValidationSummary, Validators, Version=1.0.0.0"/>
  83.             </tagMapping>
  84.         </pages>
  85.         <!-- 
  86.           Set compilation debug="true" to insert debugging 
  87.           symbols into the compiled page. Because this 
  88.           affects performance, set this value to true only 
  89.           during development.
  90.     -->
  91.  
Apr 22 '07 #5

P: 8
Part 2:
Expand|Select|Wrap|Line Numbers
  1. <compilation debug="true">
  2.             <assemblies>
  3.                 <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  4.                 <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  5.                 <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  6.                 <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  7.                 <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  8.                 <add assembly="System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  9.                 <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  10.                 <add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  11.                 <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  12.                 <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  13.                 <add assembly="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  14.                 <add assembly="System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  15.                 <add assembly="System.Runtime.Serialization.Formatters.Soap, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  16.                 <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  17.                 <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  18.                 <add assembly="System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  19.                 <add assembly="DevExpress.Data.v6.3, Version=6.3.2.0, Culture=neutral, PublicKeyToken=79868B8147B5EAE4"/>
  20.                 <add assembly="DevExpress.Utils.v6.3, Version=6.3.2.0, Culture=neutral, PublicKeyToken=79868B8147B5EAE4"/>
  21.                 <add assembly="DevExpress.XtraPrinting.v6.3, Version=6.3.2.0, Culture=neutral, PublicKeyToken=79868B8147B5EAE4"/>
  22.                 <add assembly="DevExpress.XtraReports.v6.3, Version=6.3.2.0, Culture=neutral, PublicKeyToken=79868B8147B5EAE4"/>
  23.                 <add assembly="DevExpress.XtraEditors.v6.3, Version=6.3.2.0, Culture=neutral, PublicKeyToken=79868B8147B5EAE4"/>
  24.                 <add assembly="DevExpress.XtraBars.v6.3, Version=6.3.2.0, Culture=neutral, PublicKeyToken=79868B8147B5EAE4"/>
  25.                 <add assembly="DevExpress.XtraCharts.v6.3, Version=6.3.2.0, Culture=neutral, PublicKeyToken=79868B8147B5EAE4"/>
  26.                 <add assembly="DevExpress.XtraRichTextEdit.v6.3, Version=6.3.2.0, Culture=neutral, PublicKeyToken=79868B8147B5EAE4"/>
  27.                 <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  28.                 <add assembly="DevExpress.XtraNavBar.v6.3, Version=6.3.2.0, Culture=neutral, PublicKeyToken=79868B8147B5EAE4"/>
  29.                 <add assembly="DevExpress.Web.ASPxDataControls.v6.3, Version=6.3.2.0, Culture=neutral, PublicKeyToken=79868B8147B5EAE4"/>
  30.                 <add assembly="System.Drawing.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  31.                 <add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  32.                 <add assembly="Microsoft.Build.Utilities, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  33.                 <add assembly="Microsoft.Build.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  34.                 <add assembly="vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>
  35.             <buildProviders>
  36.                 <add extension="*.asbx" type="Microsoft.Web.Preview.Services.BridgeBuildProvider"/>
  37.             </buildProviders>
  38.         </compilation>
  39.         <authentication mode="Forms">
  40.             <forms name=".ASPXAUTH" loginUrl="Default.aspx" protection="All"/>
  41.         </authentication>
  42.         <authorization>
  43.             <deny users="?"/>
  44.             <!--swith this to deny to turn on logon-->
  45.         </authorization>
  46.         <!--
  47.           ASMX is mapped to a new handler so that proxy javascripts can also be served.
  48.     -->
  49.         <httpHandlers>
  50.             <remove verb="*" path="*.asmx"/>
  51.             <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  52.             <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  53.             <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
  54.         </httpHandlers>
  55.         <httpModules>
  56.             <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  57.             <add name="EntityTransactionModule" type="XXXXX.Web.Data.EntityTransactionModule"/>
  58.         </httpModules>
  59.         <!--<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
  60.           <error statusCode="403" redirect="NoAccess.htm"/>
  61.           <error statusCode="404" redirect="FileNotFound.htm"/>
  62.       </customErrors>-->
  63.         <globalization requestEncoding="UTF-8" responseEncoding="UTF-8" fileEncoding="UTF-8" enableClientBasedCulture="false" responseHeaderEncoding="UTF-8" resourceProviderFactoryType="" enableBestFitResponseEncoding="false" culture="auto" uiCulture="auto"/>
  64.     </system.web>
  65.     <location path="GeneralError.aspx">
  66.         <system.web>
  67.             <authorization>
  68.                 <allow users="?">
  69.                 </allow>
  70.             </authorization>
  71.         </system.web>
  72.     </location>
  73.     <location path="PageNotFound.aspx">
  74.         <system.web>
  75.             <authorization>
  76.                 <allow users="?">
  77.                 </allow>
  78.             </authorization>
  79.         </system.web>
  80.     </location>
  81.  <system.webServer>
  82.         <validation validateIntegratedModeConfiguration="false"/>
  83.         <modules>
  84.             <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  85.         </modules>
  86.         <handlers>
  87.             <remove name="WebServiceHandlerFactory-Integrated"/>
  88.             <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  89.             <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  90.             <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  91.         </handlers>
  92.     </system.webServer>
  93. </configuration>
  94.  
Apr 22 '07 #6

P: 8
The App Pool Settings are as below:

*Recycle Tab
Recycle Worker Process (mins) 40
Recycle Worker Process (requests) 3000
Max virtual memory 500
Max used memory 512

*Performance Tab
Shutdown worker processes ... 10
Limit the kernal queue (requests) 1000
Web Garden worker processes 12

*Health
Ping worker process every 30
Failures 5
Time period 5
Worker process startup 90
Shutdown 90

*Identity
Predefined - Network Service

Looks fine to me but maybe someone can spot something.
Apr 22 '07 #7

P: 8
No joy on this one so far, anyone have any ideas
Apr 24 '07 #8

Motoma
Expert 2.5K+
P: 3,235
I am coming at this thread with almost no IIS session experience.

Have you gone into the database to see that the session is actually gone? If so, fire up the SQL Profiler in Enterprise Manager and see if there is anything that may be causing that. Perhaps you are forgetting to do a commit?

In other languages, maintaining a session requires the session id to be stored client side. This is usually done through a cookie. What may be happening is your cookie is getting invalidated or expired a couple times a day. How does your system draw a link between a user and the session information?
Apr 24 '07 #9

P: 8
hi the session data is still there as it can be brought back with an IIS reset. I'll look into the cookie issue bt it shouldn't cause all sessions to die at the same moment. Thought someone else might have faced this one.
Apr 25 '07 #10

pkreemer
P: 13
Joe, do you get this problem when your app isn't setup on a web garden? And it doesn't happen periodically, but more randomly?

No real help from me, just thinking of things that might be involved.

Paul
Apr 25 '07 #11

Post your reply

Sign in to post your reply or Sign up for a free account.