Session timeouts in asp.net on a dedicated server - asp.net

I have a asp.net website hosted in the dedicated server.I'm using web.config to handle the session timeouts and that is 60 minutes.I did the following settings on the dedicated server (windows server 2003 and IIS 6.0 versions)
In the default web site property of IIS-->ASP.net tab-->Edit configuration-->Session timeouts -->60
In the application pool The session timeout has been extended to 60.
Recycling worker process has been set to 60 in the application pool.
I can get this work correct on my local system the problem is on the dedicated server(Goddady). No customer support is available for this problem
It will be also fair if the session timeout is infinity too.
But the timeout occurs after every 20 minutes if the webform is kept idle. How to get rid of this? I have a guess that the idle timeout is overriding the session timeout as I googled around but have not found a solution for this
please help me........
Thanks,
Prabha

We had the same problem on a hosted server, and decided that rather than fighting with the hosting company we would use some javascript on a timer to execute an AJAX request to the server to reset the session if it was about to expire.
This site (PreventTimeout) is very close to what we do.
I know this doesn't answer your question directly, but it has been a good workaround for us.

If you recycle the application pool every 60 minutes, then (assuming your sessions die when the pool recycles) a session started 10 minutes before the pool recycles will only last 10 minutes.
On average, you'd expect a session to last 30 minutes.

Related

How to change idle timeout asp mvc app on my shared hosting provider?

I have a site on a shared hosting provider. My site timeouts when on idle and can take up to 40 seconds to start up again, I want to increase the idle timeout. Under manage - Dedicated IIS application Pool, the idle timeout is set to 5 minutes I want to increase it, I called my provider and they said I am unable to change the settings with a shared hosting account. I was thinking if there was another way Like the web.config folder to increase the timeout time?
The app pool is likely being recycled. There's nothing you can do about this on a shared hosting service. What you can do is send pings to the web server every N minutes. If GoDaddy recycles the app pool every 5 minutes, then send a ping to your website every 4 minutes. Doing this should extend the timeout an additional 4 minutes. If you always do this, it should not recycle unless explicitly called (or unless the host has some other recycle in place).
Optionally, you can use a monitoring service that pings and reports on your server. Here are two that may be of use to you: https://uptimerobot.com/ https://www.pingdom.com/
Uptime services that I've tried didn't actually send HTTP requests to the web app so it didn't help in keeping it alive. However, I found a nice feature in Application Insights called Availability which lets you create recurring tests that actually send GET requests to your website, thus preventing it from recycling.
I explain it more in my blog post here.
Open task scheduler on your computer
Create a scheduled task to run every 4 minutes
Have it run a powershell command invoke-webreqest to your site.
It'll have the effect of someone visiting your site every 4 minutes.

Low Traffic Website - Slow Initial Load

I have a problem with my website and I think it's related to IIS recycling the app pool or shutting down the app after 20 mins of inactivity. As it is a low traffic site, when I first browse to the site the initial load can take up to 30 seconds, then after that it is very fast. If i then come back to the site say a few hours later I get the slow load time again. I'm sure it's something to do with the app pool shutting down after 20 mins of inactivity?
Another problem is that I am hosting via a hosting company so have no direct access to manipulate IIS at all. Does anyone know how I can keep my app alive so I don't suffer from the initial slow load speed issues?
You could setup a service to issue a request every few minutes to your site which can double as monitoring your site to ensure it's still running. You probably don't have access to the application pool configuration I assume.

web app slow performance when leave idle for some time

We have a web application deployed on IIS 7.5 target framework 4.0
the application perform slow when leave idle for few minutes for first time and then perform as expected this happened each time application is idle.
With the help of fiddler I found its TCP/IP connection which is taking time about 21 secs whilein subsequent calls this time is 0.
The Idle time out is also set high and connection time out is also high in the IIS settings.
server is - Windows 2008 R2.
there is nothing in the event viewer related to the website.
we used form authentication but the time out for that is also set about 10 hours in the config file.
Can anybody point me to the setting with is affecting the response time after the app is idle for some time.
Note - this was working proper when deployed withing the LAN but this problem starts when deployed out of the LAN or in separate domain.
Problem
here is the problem in IIS app pool idle time out, its by default set to 20 minutes, after 20 minutes app pool shutdown if no request within 20 minutes,
when any request comes after 20 minute its again start,
The problem is that the first visit to an app pool needs to create a new w3wp.exe worker process which is slow because the app pool needs to be created, ASP.NET or another framework needs to be loaded, and then your application needs to be loaded. so it may take time 20-30 seconds or depends on the application content size.
Solution
so to avoid this type of delay we need to set the idle time out to 0.
now it will always load fast.
app pool setting
The IIS application pool is shut down after 30 minutes of inactivity. After that, when you make a request IIS basically has to start the website up again, which leads to the behavior you are describing. You can change the idle time of your website in IIS though to avoid it.
You could also look into the Auto-Start feature of the 4.0 framework.
Well, a bit late, but may help someone else. I had the same problem, nothing in the logs, spent days, then looking at the network adapter properties / configuration / power management - Allow computer to shut down save power was checked. Unchecked and the problem was solved.

ASP.NET Session Recycles

In an ASP.NET website we are storing sessions in SQL Server. All is working fine except that sessions frequently recycle. I've a timeout period set to 30 minutes but some times it recycles within a few minutes. We've a dedicated server, and website running under a 'classic' application pool. I've searched a lot on this problem, but didn't find a satisfactory answer. Any help will be greatly appreciated.
Note: mostly it happens on a page where there is lots of use of viewstate, I'm curious that is there a link of viewstate with session recycling?
We've experienced this problem when we either have a web farm (more than one web server servicing clients) or a web garden (more than one worker process in an application pool).
If you have a web farm, then you need to ensure that all web servers have the same machine key and that all instances have the exact same application path.
If you have a web garden, try dropping the maximum worker processes back to 1 to see if that resolves the issue.
While you are checking the IIS settings, you should probably also ensure that the application pool is not recycling regularly. This can be due any of the following specified in the app pool:
1) Private Memory Limit (the app pool is reset if the maximum amount of memory has been exceeded)
2) Regular Time Interval recycling (the app pool is automatically recycled after a specified number of minutes, defaulting to 1740, and/or at specific times).
3) Idle Time-out (the number of minutes of inactivity that can elapse before the application pool is automatically shutdown).
You should also check the event logs for reports of the application pool crashing or otherwise being recycled.
Update:
An additional thought:
If you have an application, such as anti-virus or backup software, that monitors your application's bin directory and modifies or changes attributes (such as the backup flag or timestamp) of files in that directory OR your web.config file, this will cause application recycling as well.

ASP.NET web app slow response after a pause

I'm building a web app using ASP.NET MVC and MS SQL Server CE and deploying it to a shared hosting. Every time I approaching my site after a pause (half an hour) it performs very slow. It takes about 40 seconds to load the first page. After this every page opens quickly.
Please advice what may cause the problem and how to solve it.
Thanks
Update: It appeared that after a pause in visiting (10-20 min) the site is loaded from the server hard drive not memory. That is why it was so slow. Possible solutions are increase site visits, move to a virtual server or ping the home page regulary.
My hosting provider has an option for pinging besides some solutions are described here c# ping a website? (keep-alive service)
If the worker process is not processing requests it will shut down the worker process after the specified number of minutes. (if configured)
Not sure what version of IIS you are using but look into "Idle Time-out (minutes)". IIS 7 specific info below...
http://technet.microsoft.com/en-us/library/cc771956(WS.10).aspx
As a paliative, set your app to recycle only after a long period of inactivity.
See Configure an Application Pool to Recycle at a Scheduled Time (IIS 7)

Resources