C# 如何解决“HTTP 错误 404.3 - 未找到”错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1528324/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 18:27:29  来源:igfitidea点击:

How to solve a "HTTP Error 404.3 - Not Found" error?

c#visual-studio-2008iis-7wcfhttp-status-code-404

提问by Wim ten Brink

Simple problem. I start up VS2008 and create a new WCF Service application. This will create a default application with a few test methods showing it works. I press CTRL+F5 and it does indeed work! Great! However, it uses the Visual Studio Development server, which I don't want to support.

简单的问题。我启动了 VS2008 并创建了一个新的 WCF 服务应用程序。这将创建一个默认应用程序,其中包含一些显示其有效的测试方法。我按 CTRL+F5 确实有效!伟大的!但是,它使用了我不想支持的 Visual Studio 开发服务器。

So I go to the project properties, switch to using a local IIS Web server, create the virtual directory and press CTRL+F5 again. And this "HTTP Error 404.3 - Not Found" error is greeting me back.

所以我转到项目属性,切换到使用本地 IIS Web 服务器,创建虚拟目录并再次按 CTRL+F5。这个“HTTP 错误 404.3 - 未找到”错误正在向我致意。

So something in my IIS7/Vista-64 setup is wrong. What could I be missing?

所以我的 IIS7/Vista-64 设置中的某些东西是错误的。我可能会错过什么?

采纳答案by bendewey

Click Start -> Run cmdand type:

单击开始 -> 运行cmd并键入:

cd "\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation"
ServiceModelReg.exe -i

回答by Doguhan Uluca

The problem, however, is then to re-register ASP.Net to IIS, which is explained below.

然而,问题是将 ASP.Net 重新注册到 IIS,这将在下面解释。

And also if you're on a 64bit machine always use Framework64 paths: C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis.exe -iru

而且,如果您使用的是 64 位机器,请始终使用 Framework64 路径:C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis.exe -iru

Below is the explanation from Microsoft:

以下是微软的解释:

http://download.microsoft.com/download/0/A/E/0AEB3BC1-506E-4954-8AB1-4FA2EE75985C/ReleaseNotes.docx

http://download.microsoft.com/download/0/A/E/0AEB3BC1-506E-4954-8AB1-4FA2EE75985C/ReleaseNotes.docx

When attempting to run a service that receives messages over the HTTP transport, you may receive an error similar to the following:

尝试运行通过 HTTP 传输接收消息的服务时,您可能会收到类似于以下内容的错误:

Server Error in '/WCFApplication' Application

“/WCFApplication”应用程序中的服务器错误

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

无法从程序集“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”加载类型“System.ServiceModel.Activation.HttpModule”。

Description: An unhandled exception occurred during the execution of the current Web request. Review the stack trace for more information about the error and where it originated in the code. Exception Details: System.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

说明:在执行当前 Web 请求期间发生未处理的异常。查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。异常详细信息:System.TypeLoadException:无法从程序集“System.ServiceModel,Version=3.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”加载类型“System.ServiceModel.Activation.HttpModule”。

This error can occur when IIS is installed after installing .NET Framework 4, or if the 3.0 version of the WCF Http Activation module is installed after installing IIS and .NET Framework 4.

在安装 .NET Framework 4 后安装 IIS 时,或者安装 IIS 和 .NET Framework 4 后安装 3.0 版本的 WCF Http 激活模块时,可能会出现此错误。

To resolve this problem, you must use the ASP.NET IIS Registration Tool (Aspnet_regiis.exe,) to register the correct version of ASP.NET. This can be accomplished by using the –iru parameters when running aspnet_regiis.exe as follows:

要解决此问题,您必须使用 ASP.NET IIS 注册工具 (Aspnet_regiis.exe) 来注册正确版本的 ASP.NET。这可以通过在运行 aspnet_regiis.exe 时使用 –iru 参数来完成,如下所示:

aspnet_regiis.exe -iru

aspnet_regiis.exe -iru

And credit, where it's due: Source

和信用,它到期的地方:来源

回答by GONeale

I had to tick "HTTP Activation" in "Add Role Services" within Windows Server 2012.

我必须在 Windows Server 2012 中的“添加角色服务”中勾选“HTTP 激活”。

回答by Mr.Buntha Khin

try to install IIS by expanding your Internet information service and then check ASP.Net 3.5 or ASP.Net 4.5 and ISAPI.... in root of world wide......... please look image to more helpenter image description here

尝试通过扩展您的 Internet 信息服务来安装 IIS,然后在 World Wide 的根目录中检查 ASP.Net 3.5 或 ASP.Net 4.5 和 ISAPI ..... 请查看图像以获得更多帮助在此处输入图片说明

回答by Yazan Fahad Haddadein

If you faced this problem for the first time. with Windows 8 and IIS 8.0 make sure to activate Windows Communication Foundation HTTPwindows feature.

如果您是第一次遇到这个问题。使用 Windows 8 和 IIS 8.0 确保激活Windows Communication Foundation HTTPwindows 功能。

  1. Go to Control Panel select "Programs and features"
  2. From the lift hand side menu select "Turn Windows features on or off".
  3. Expand ".Net Framework 3.5 (includes .NET 2.0 and 3.0)"item
  4. Finally select "Windows Communication Foundation HTTP Activation"
  5. Enjoy your WCF Servcie.
  1. 进入控制面板选择“程序和功能”
  2. 从电梯手边菜单中选择“打开或关闭 Windows 功能”
  3. 展开“.Net Framework 3.5(包括 .NET 2.0 和 3.0)”
  4. 最后选择“Windows Communication Foundation HTTP Activation”
  5. 享受您的WCF 服务

回答by Janspeed

I tried running ServiceModelReg and aspnet_regiis.exe with various flags and added HTTP Activation feature but it still didn't work. What finally worked was adding the following handler manually to my web.config file.

我尝试使用各种标志运行 ServiceModelReg 和 aspnet_regiis.exe 并添加了 HTTP 激活功能,但它仍然无法正常工作。最终起作用的是将以下处理程序手动添加到我的 web.config 文件中。

<system.webServer>
    <handlers>
      <add name="svc-Integrated" path="*.svc" verb="GET,HEAD,POST,DEBUG" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" modules="ManagedPipelineHandler" scriptProcessor="" resourceType="Unspecified" requireAccess="Script" allowPathInfo="false" preCondition="integratedMode" responseBufferLimit="4194304" />

My project was running .Net 3.5 and IIS was 7.5 and 7.0.

我的项目运行的是 .Net 3.5,IIS 是 7.5 和 7.0。