2
votes

I have a simple test application (C# console application) that does an HTTP GET to a .NET resource:

static void Main(string[] args)
    {
        while (true)
        {
            try
            {
                System.Net.WebRequest req = System.Net.WebRequest.Create("http://ranger/roztest/Default.aspx");

                System.Net.WebResponse resp = req.GetResponse();
                System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());

                Console.WriteLine(DateTime.Now.Ticks.ToString() + " - " + sr.ReadToEnd().Trim());
            }
            catch (Exception ex)
            {
                Console.WriteLine(DateTime.Now.Ticks.ToString() + " - " + "An Exception has occured: " + ex.GetType().ToString() + " - " + ex.Message);
            }

            Thread.Sleep(2000);
        }
    }

If I execute the following command:

net stop w3svc

IIS will stop. The command line utility that I wrote will return a System.Net.WebException "(404) Not Found".

If IIS is stopped, which process is returning that 404?

Is it the svchost.exe that contained the IIS service?

Background Information:
I'm running that Default.aspx page under IIS 7 on Windows 7 (x64) Professional.

The WebException is being thrown on the "req.GetResponse()" line.

2

2 Answers

2
votes

More clues emerge:

Check out the following post from Mike Volodarsky:

Starting with Windows 2003, IIS uses the http.sys kernel driver to listen for requests, and the W3SVC service to configure it to listen for requests on all binding endpoints associated with your site. On IIS7, the service doing most of the work is now called WAS (even though W3SVC is till needed). A configuration error can cause WAS/W3SVC to fail to start a site, and therefore http.sys will not receive requests on its endpoints. Also, there is the off chance that the site definition itself is missing, or the site does not define the right bindings.

And even a tool to configure the http.sys driver.

0
votes

I believe (if you truly are connecting to a server which is simply not responding) it might be the .NET network stack itself that is throwing the exception -- probably related to a connection timeout.