views:

41

answers:

2

Question: When a webapplication gets started, it executes Application_Start in global.asax.

Now, a web application gets started as soon as the first request for a page in that application reaches the server.

But my question is: how long will the application run until the application is stopped. I mean when after the first page request, there's no traffic on the server.

I need to know because I intend to start a server that listens on a tcp port in global.asax. And when the application stops, the server ceases to listen to its port.

+3  A: 

It depends on your IIS settings. Your application will run in an application pool, which takes a bunch of settings defining the behaviour of this pool.

The thing you're looking for are recycling settings. In IIS 7, you can access these easily from the management console. Go to Application Pools, right click on the application pool your app runs in (if you don't know which one that is, then it's probably the DefaultAppPool) and select recycling.

Here you'll find the options you have to control the recycling behaviour of your app pool, which in turn controls when your app 'resets'.

Erik van Brakel
Good. So now I use pingalive to keep it alive ;-))
Quandary
+2  A: 

in a word (well 2) - shared hosting.

on shared hosting beware, (godaddy/webhost4life etc) this timeout could well be less, plus you don't have option to configure that on these hosting environments. i've had cases where the app pool is recycled after 5 mins at certain peek times, so you might have to investigate 'wakeup' routines to poke your app to keep in in the memory. i do this for a few shared hosting apps to great effect using pingalive.com.

hope this helps, even if in an abstract way.

jim

jim
Basically - it doesn't answer my question - but pingalive solves the underlying problem ;-))
Quandary
quandary - glad to have been of assistance. i've actually continually found that on SO - i.e. the response doesn't answer my question but does address the issue. it's a kinda magic :) - cheers again
jim