已部署的 Web 核心 API:响应状态代码不表示成功:404(未找到)。
Deployed Web Core API: Response status code does not indicate success: 404 (Not Found).
我部署了一个新应用程序,其中包含一个与 Web 核心通信的 Web 项目 API。
我是参考这个link来设置的;
https://docs.microsoft.com/en-us/aspnet/core/publishing/iis
IIS已经在本测试服务器上架设了一段时间,所以有些步骤就不用重复了。
在 IIS 中,如果我浏览 Web API 将按如下方式启动。
但是如果我对使用它的网络项目也这样做,我会收到这个错误:
Response status code does not indicate success: 404 (Not Found) for a simple get call to the Web API.
我应该考虑什么来解决这个问题?
我看到了多种可能性
- 您刚刚浏览到根 url 而您在 IIS 中没有任何 default page setup。要查看 Web API,请浏览到您在 route.config 文件中指定的 webapi url。
根据您的 routing 默认路线将是这样的。您可以浏览到
http://testweb.sherrygreengrp.com/api/<controller>
- 您没有 Windows 服务器托管包
Install the .NET Core Windows Server Hosting bundle on the hosting
system. The bundle will install the .NET Core Runtime, .NET Core
Library, and the ASP.NET Core Module. The module creates the
reverse-proxy between IIS and the Kestrel server. Note: If the system
doesn't have an Internet connection, obtain and install the Microsoft
Visual C++ 2015 Redistributable before installing the .NET Core
Windows Server Hosting bundle
ASP.NET CORE Module 配置正确。您的 web.config
中是否有此设置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%"
arguments="%LAUNCHER_ARGS%"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
我发现我在部署服务器上需要的 URI 需要有我的应用程序的名称,而在开发中则不需要。一旦我进行了该更正,它就可以正常工作。
我部署了一个新应用程序,其中包含一个与 Web 核心通信的 Web 项目 API。
我是参考这个link来设置的;
https://docs.microsoft.com/en-us/aspnet/core/publishing/iis
IIS已经在本测试服务器上架设了一段时间,所以有些步骤就不用重复了。
在 IIS 中,如果我浏览 Web API 将按如下方式启动。
Response status code does not indicate success: 404 (Not Found) for a simple get call to the Web API.
我应该考虑什么来解决这个问题?
我看到了多种可能性
- 您刚刚浏览到根 url 而您在 IIS 中没有任何 default page setup。要查看 Web API,请浏览到您在 route.config 文件中指定的 webapi url。
根据您的 routing 默认路线将是这样的。您可以浏览到
http://testweb.sherrygreengrp.com/api/<controller>
- 您没有 Windows 服务器托管包
Install the .NET Core Windows Server Hosting bundle on the hosting system. The bundle will install the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. The module creates the reverse-proxy between IIS and the Kestrel server. Note: If the system doesn't have an Internet connection, obtain and install the Microsoft Visual C++ 2015 Redistributable before installing the .NET Core Windows Server Hosting bundle
ASP.NET CORE Module 配置正确。您的 web.config
中是否有此设置<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /> </system.webServer> </configuration>
我发现我在部署服务器上需要的 URI 需要有我的应用程序的名称,而在开发中则不需要。一旦我进行了该更正,它就可以正常工作。