Solved

Session variables expiration ASP.NET C#

Posted on 2016-09-23
3
63 Views
Last Modified: 2016-09-23
We have an application that uses session variables in this form:

Session["FirstName"] = "test";

Open in new window


And we collect like this in other pages:

result = Convert.ToString(Session["FirstName"] );

Open in new window


We are using one Application Pool configured with NET 4, Enable 32 bits apps,  queue length 1000, Identity:ApplicationPoolIdentity and Idle timed out we changed from 20 to 1000.

We changed the idle time from 20 to 1000 because we noted in event viewer we found this warning:"A worker process with process id of '18404' serving application pool 'webapplication' was shutdown due to inactivity.  Application Pool timeout configuration was set to 20 minutes.  A new worker process will be started when needed."

After change the 20 to 1000 the warning is no more in the event viewer like if was solved the issue of our main problem. This is our main problem:

Now the real reason we changed from 20 to 1000 in idle time is because if we  have opened the browser and inactive for some time the application then the session variables loss their values. Then the change from 20 to 1000 not work at all because the session variables continue losing their values.

How can we solve the session variables loss their values?
0
Comment
Question by:Alex E.
3 Comments
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 41812816
1. set sessiontimeout in web.config.
2. Set session timeout to 60 minutes in IIS manager/Web site properties/ASP.NET configuration settings.
3. Set idle timeout to 60 minutes in application pool properties/performance.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 41813187
The application pool effectively is the instance of your application in memory. If you are using in-memory session (which is the default), then once your app pool is shut down, session is gone. This is the same thing that would happen if your web application were a console application and you closed the console window while the app was running. If you want to persist the session across application restarts, then you will to move away from in-memory session to something like storing session in a database or some other session provider.
0
 

Author Closing Comment

by:Alex E.
ID: 41813261
Exactly I tried everything including change all asp.net timeouts and nothing. I switched to  "Stateserver" and problem gone. Here is what I used:

<sessionState mode="StateServer" stateConnectionString="tcpip=localhost:42424" stateNetworkTimeout="56000" timeout="56000">
    </sessionState>
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
encoding an href string 2 20
Need to learn more about SecurityProtocolType.Tls12 3 27
VB.NET 2008 Publish Error 2 24
Linq asp.net mvc 13 6
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now