[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Session Variables die well before time set in web.config

Posted on 2008-10-09
12
Medium Priority
?
550 Views
Last Modified: 2013-11-08
I store a userid in a session variable and 2 of my pages have updatepanels that refresh with an asp:timer, these pages, and a few without the timer, do not maintain the session variable and pass "NULL" when a commandbutton for DB update is passed.

I am fairly new to .NET (about a year) and never had this issue with classic ASP sessions.
<authentication mode="Forms">
      <forms timeout="60" cookieless="AutoDetect" loginUrl="default.aspx" defaultUrl="tb_main_menu.aspx" />
    </authentication>
      <sessionState cookieless="AutoDetect" timeout="60" />

Open in new window

0
Comment
Question by:cwickens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 22682279
0
 
LVL 5

Author Comment

by:cwickens
ID: 22687929
It show (and all the examples show) use of a sqldatabaseconnection in the web.config.

Ok, that brings up another question, if I switch to stateServer mode, is this connection needed and if not, is this the connection to my app's DB or is there a default db used by the process?
0
 
LVL 5

Author Comment

by:cwickens
ID: 22687990
the other question, which may be the root cause, is: If I have a timer on the page (AJAXControlToolkit, asp:timer) and when the timer fires, the updatePanel on the page updates, does that count as an activity that will keep the session alive?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 22688015
using the stateServer mode will solve your session dissapearing problem

for your dbv connection use this: in your web.config

<connectionStrings>
            <add name="DBConnection" connectionString="Data Source=SERVERIP;Network Library=DBMSSOCN;Initial Catalog=MYDBNAME;User ID=MYDBUSERNAME;Password=MYDBPASSWORD;"
        providerName="System.Data.SqlClient" />
      </connectionStrings>

then when you want to use this code in your C#: do this:

connString = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
0
 
LVL 13

Accepted Solution

by:
copyPasteGhost earned 2000 total points
ID: 22688073
0
 
LVL 5

Author Comment

by:cwickens
ID: 22688089
I gues I must be making this more difficult than I need to, but, is this a separate connection from the one I already have to my 'live' database?

Sorry for the braindead appearance of the question, however, I have been debugging this application after going to production and this is the only issue I have left to resolve...5 days and counting with about 3 hours of sleep a night, I am running on coffee at this point.  :)
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 22688124
if you already have a connection why are we trying to make a new one?

leave that code out. I thought you needed to know how to make a connection string in your web.config.....

I'm in the same situation! (Sleep Deprivation) Deadlines are fun!

Hope that clearifies things. If not ask away I'm here.
0
 
LVL 5

Author Comment

by:cwickens
ID: 22688262
ok, that helps, so just to bring it back around...

I can leave the session state in the web.config to default and include the jscript/aspx page from the link you sent and basically be done, right?
-OR-
If I use stateserver, I can leave out the reference to the sqldatabaseconnection in the web.config since the connectionstring is already defined like this:
<sessionState mode="StateServer"
      stateConnectionString="tcpip=SampleStateServer:42424"
      cookieless="false"
      timeout="20"/>
 
<bouncing head off keyboard> 9oo2erhkxaireuadofbi84adf98 </bouncing head off keyboard>
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 22688310
<sessionState mode="StateServer"
      stateConnectionString="tcpip=SampleStateServer:42424"
      cookieless="false"
      timeout="20"/>

this stores where the session state is stored.....not a connection to your database....you will need both. or you can lose the session state stuff...unless you need it. (I never include that)

Check here for more info about the session state:  
http://msdn.microsoft.com/en-us/library/system.web.configuration.sessionstatesection.stateconnectionstring.aspx

But besides that...you got it!
0
 
LVL 5

Author Closing Comment

by:cwickens
ID: 31504799
Thanks!
0
 
LVL 5

Author Comment

by:cwickens
ID: 22711581
I wanted to wait until today (after the holiday weekend) to see if there would be any issues with this.

I appear to have resolved this issue and even got 3 solid nights of sleep thanks to your assistance!

V/r,
chuck
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 22711593
you are welcome. thanks for the grade
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question