gpt4 book ai didi

c# - 什么进程返回 "(404) Not Found"错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:53:27 24 4
gpt4 key购买 nike

我有一个简单的测试应用程序(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 页面。

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

最佳答案

出现更多线索:

查看以下 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.

甚至是 tool to configure the http.sys driver .

关于c# - 什么进程返回 "(404) Not Found"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1413577/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com