|License Type||SaaS & On-Premise|
|Agent Mode||Assess & Protect|
|Main Product Category||.NET Framework Agent & .NET Core Agent|
My servers and/or .NET Framework and .NET Core applications running under IIS will often show up as offline in the Contrast UI but then appear online again sometime later. Why is that?
The Contrast Agent profiler instrumenting your .NET Framework or .NET Core application in IIS, runs within the worker process serving that application, and will regularly report back to the Contrast UI with a heartbeat indicating that it is online. The profiler is only loaded by IIS when traffic is first seen by the application. Consequently, if the Contrast Agent profiler has not yet been loaded, or if the worker process is not running, no such heartbeat will be sent, resulting in the application appearing offline after a period of approximately 15 minutes, and the server appearing offline after about an hour.
By default, IIS does not start an application pool (and the associated worker process or processes) until traffic is received for the application. This behavior is controlled by the application pool setting Start Mode which defaults to OnDemand. To change this behavior, you can set the Start Mode to AlwaysRunning:
This change will cause the application pool and worker process(es) to start with IIS, however note the caveat above that the Contrast Agent profiler will not be loaded until traffic is seen by the application.
In addition, Application pools have a default behavior of terminating after a period in which the application is idle (i.e. no traffic) - that default is 20 minutes - and will recycle after a default of 1740 minutes (29 hours).
If either of these events occurs, the worker process will be restarted either immediately (if the Start Mode is AlwaysRunning) or when traffic is directed through the application (if Start Mode is OnDemand). Again, as noted above, this new process will only load the Contrast Agent profiler when traffic is directed through the application, so it is possible to see running worker processes but an offline status in the Contrast UI.
An alternative to directing traffic through an application to "warm up" the application pool, is to install the IIS Application Initialization Role or Feature and set the Preload Enabled option to true in the application's Advanced Settings:
This will cause the worker process(es) to load the Contrast Agent profiler as soon as the process starts up, either after an IIS Reset or process restart following an idle timeout or recycle.