Gen Question - Verify Web Page

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've written a quick .net based intranet utility that checks server status
and app status.

I need to make sure a web server is up and running. My idea is to request a
web page and load it into a buffer. If an exception occurs, something's
wrong. Would I find such functionality in System.Web, System.Net, ...? I
don't want to display the web page, just ensure it loads correctly. Is there
a better way to check that a web server is running?

Any Ideas?

--Billg_sd
 
To do this properly you should use WMI or even better if you have the time
you could write a WMI consumer. I only have access to newsgroups here and
not internet but you should find an example using a search engine and
entering keywords like "System.Management" "WMI" "IIS"

Eg (query the processes):

ManagementObjectSearcher serviceSearcher = new
ManagementObjectSearcher("SELECT * from Win32_Service");
foreach (ManagementObject service in serviceSearcher.Get())
{
Console.WriteLine(service["Name"] + " / " + service["Description"] + " /
" + service["Status"] );
}
Console.Read();

For a list of all the properties you can search the MSDN for "Win32_Process
class [WMI]" and you can adjust the WQL statement and add a filter on Name
and Status for instance.

Gabriel Lozano-Morán
 
Imports System.Net

Private Function WebAppOnLine(ByVal sURL As String) As Boolean
Try
Dim myRequest As WebRequest = WebRequest.Create(sURL)
Dim cache = New CredentialCache

cache = System.Net.CredentialCache.DefaultCredentials
myRequest.Credentials = cache

Dim myResponse As WebResponse = myRequest.GetResponse()
myResponse.Close()
WebAppOnLine = True
Catch Exc As System.Net.WebException
WebAppOnLine = False
End Try
End Function

This works great for checking IIS based websites (in my intranet), but not
Java (JSP) based websites/Servers. Is there more a generic, platform
independent library call that can determine if a web site is up and running?
 
Back
Top