Session State Key and SQL Session

Discussion in 'ASP.NET / ASP.NET Core' started by tcdrifter, Mar 12, 2008.

  1. I have an .aspx page connected to a SQL dbase that does a lot of calculations prior to presenting a client's data (among lots of other client's data). The page takes about 14 seconds to display. That is ok and not the problem.

    The problem is that when the page is either repeatedly refreshed or other pages of the DataGrid are accessed about 4 to 8 times, the Session Key is lost. If you hit the back button, the user must log in again.

    The short history is...
    Working with DASP, we changed the SQL dbase to "SQL Session" from "InProc" andI re-uploaded my dbase and reattached it. I assumed we needed to do this from the DASP support message that said...


    We recycle an application if any of the following criteria are met:
    1 - Average usage of 75% of the CPU over a 5 minute period
    2 - Usage of more than 100MB of memory
    3 - Application Idle for more than 20 minutes

    If an application is reset, the session information will be lost as
    well. We suggest you try to run the application in your local environment
    to see which of the above criteria is most likely the culprit.
    Additionally, we suggest you store session information in SQL server to avoid
    such issues. Please refer to the following regarding storing session
    information in SQL.
    </BLOCKQUOTE>
    I guessI am breaking either number 1 or 2 above. (??)
    Then, from KB 10350, the following was added to the web.config file just after "Configuration" and before "connectionStrings".
    <sessionState
    mode="SQLServer"
    allowCustomSqlDatabase = "true"
    sqlConnectionString="data Source=<SQLSERVERNAME>;database=<SQLDATABASENAME>;
    user id=<SQLUSER>;password=<SQLPASSWORD>"
    cookieless="false"
    timeout="15" />

    Specifically...
    <sessionState mode="SQLServer"</o:p>
    allowCustomSqlDatabase = "true"</o:p>
    sqlConnectionString="data Source=tcp:sql2k511.discountasp.net;database=SQL2005_471896_aspnetdb;</o:p>
    user id=SQL2005_471896_aspnetdb_user;password=******"</o:p>
    cookieless="false"</o:p>
    timeout="15" />

    With this code it just errors out when it tries to open the login page of the site. Error message...



    Server Error in '/' Application.


    Configuration Error
    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: Unrecognized configuration section sessionState.

    Source Error:





    Code:
    Line 19:    <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup></sectionGroup></sectionGroup></configSections><appSettings/>
    Line 20: 
    Line 21:    <sessionState mode="SQLServer"
    Line 22:    allowCustomSqlDatabase = "true"
    Line 23:    sqlConnectionString="data Source=tcp:sql2k511.discountasp.net;
    Any ideas? I am new and inexperienced with pretty much everything. I am using Visual Web Developer 2008 Express, C#, SQL.
    Thank you.
     
  2. Through further study, I found that the web.config sessionState code must go in the system.web section of the web.config file.


    (One less thing to figure out.)
     

Share This Page