I want to prevent loading the web application every time a user hits the web site - for example, after it was not active for some time (the web application terminates)
I saw I can change the Idle Time-out Action in IIS to "Suspend"
What is a good way to achieve that? (any benefits for doing it through code?)
You're looking for StartMode of the IIS app pool being set to "AlwaysRunning" in the applicationhost.config file. Here's the instructions (pulled from http://developers.de/blogs/damir_dobric/archive/2009/10/11/iis-7-5-and-always-running-web-applications.aspx).
To setup the pool set the attribute startMode to AlwaysRunning of the IIS config file C:\Windows\System32\inetsrv\config\applicationHost.config:
<applicationPools>
<add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
</applicationPools>
In the same file, set the AutoStartEnabled to true:
<sites>
<site name="SomeSite" id="1">
<application path="/" serviceAutoStartEnabled="true" />
</site>
</sites>
Alternatively, you can do this through the IIS interface. Open IIS, click on the Server icon in the left column, then click on the Configuration Editor icon under Management. From the Section dropdown, choose system.applicationHost/applicationPools. There will be a Collection entry there with a Count of all your app pools. Click the little ellipses in the Count which will open a window with all your pools listed. Find your app pool in the list, make sure AutoStart is true and startMode is AlwaysRunning. Restart IIS and you'll be good to go.
Check Task Manager on the details tab, it will show you the w3wp.exe processes and the name of the app pool in the User name column. This is how you can check to make sure it is running.