【问题标题】:What process returns the "(404) Not Found" error什么进程返回“(404) Not Found”错误
【发布时间】:2009-09-11 22:36:29
【问题描述】:

我有一个简单的测试应用程序(C# 控制台应用程序),它对 .NET 资源执行 HTTP GET:

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);
        }
    }

如果我执行以下命令:

net stop w3svc

IIS 将停止。我编写的命令行实用程序将返回 System.Net.WebException "(404) Not Found"。

如果 IIS 停止,哪个进程会返回 404?

是包含 IIS 服务的 svchost.exe 吗?

背景信息:
我在 Windows 7 (x64) Professional 上的 IIS 7 下运行 Default.aspx 页面。

WebException 在“req.GetResponse()”行被抛出。

【问题讨论】:

    标签: c# iis-7


    【解决方案1】:

    更多线索浮出水面:

    查看以下post from Mike Volodarsky

    从 Windows 2003 开始​​,IIS 使用 要监听的 http.sys 内核驱动程序 对于请求,以及 W3SVC 服务 将其配置为监听请求 与关联的所有绑定端点 您的网站。在 IIS7 上,服务在做 大部分工作现在称为 WAS (尽管直到需要 W3SVC)。一种 配置错误可能导致 WAS/W3SVC 无法启动站点,并且 因此 http.sys 将不会收到 其端点上的请求。还, 该网站很有可能 定义本身缺失,或者 网站未定义权利 绑定。

    甚至是tool to configure the http.sys driver

    【讨论】:

      【解决方案2】:

      我相信(如果您真的连接到一个根本没有响应的服务器)可能是 .NET 网络堆栈本身引发了异常——可能与连接超时有关。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-16
      • 2019-12-09
      • 2018-12-16
      • 1970-01-01
      • 2012-09-20
      • 2018-04-17
      相关资源
      最近更新 更多