How to determine if a web application is currently running

I have an ASP.NET web application running under IIS 6 and another process that is responsible for monitoring and reporting.

I would like to try the web application through the monitoring process to check its status by contacting the selected handler in the web application, BUT I do not want to “wake up” the web application if it does not run.

Is it possible to determine if a particular web application is currently running? if there is such an option, I could first check if the application is running, and only then turn to the handler to check its status.

Thanks.

+7
c # iis-6
source share
6 answers

I should have done something similar earlier this year for IIS7, not sure if this will work for IIS6, but here is what I did.

var iis = new DirectoryEntry("IIS://" + Environment.MachineName + "/w3svc"); foreach (DirectoryEntry site in iis.Children) { if (site.SchemaClassName.ToLower() == "iiswebserver") { Console.WriteLine("Name: " + site.Name); Console.WriteLine("State: " + site.Properties["ServerState"].Value); } } 

ServerState returns 2 to start and 4 to stop.

+2
source share

You can use the HTTP HEAD request to check if the site is up or not. Here is an example to do the same.

http://www.eggheadcafe.com/tutorials/aspnet/2c13cafc-be1c-4dd8-9129-f82f59991517/the-lowly-http-head-reque.aspx

+1
source share

I would include the asmx file on the ASP.NET website, a web service with a simple Ping function, but it would still wake up the application pool on the website.

0
source share

You can analyze the IIS log file to see if there are any recent entries.

If your application is not used much, perhaps the last “record” should still be reset.

Or you can update the file / database to indicate "still active".

If you really don't want a delay, in Application_Start and Application_End, create and destroy the system mutex.

0
source share

This is my decision:

  try { WebRequest request = WebRequest.Create("http://localhost/"); WebResponse response = request.GetResponse(); } catch (WebException ex) { // ex.Status will be WebExceptionStatus.ConnectFailure // if the site is not currently running } 
0
source share

We used Nagios to monitor our site, and he would aim at the icon of our site. If he could drop the icon, we knew that the site was down.

0
source share

All Articles