[英]HTTP Error 404: Deployment of a Web API (minimal API NET 7) on IIS
I probably have a setup problem on IIS (it's a web server with real URL domain, so accessible from external at any time).我可能在 IIS 上遇到了设置问题(它是一个具有真实 URL 域的 Web 服务器,因此可以随时从外部访问)。 I have created a Web API with minimal API NET 7. Before testing out authetification, I tried to reach an endpoint first.
我创建了一个具有最小 API NET 7 的 Web API。在测试身份验证之前,我尝试先到达一个端点。 I named this endpoint /api/test and defined it as [AllowAnonymous] .
我将此端点命名为/api/test并将其定义为[AllowAnonymous] 。 On the development server via Swagger everything is already running (also the login or generation of tokens).
在通过 Swagger 的开发服务器上,一切都已经在运行(包括登录或令牌生成)。 But in the release web api version I commented out Swagger.
但是在发布的 web api 版本中,我注释掉了 Swagger。
Now when I install the web app on IIS server, then when I call the app via IIS server (but also when I enter the address in browser itself) I get the message: HTTP Error 404.0 - Not Found Detailed error information is:现在,当我在 IIS 服务器上安装 Web 应用程序时,然后当我通过 IIS 服务器调用应用程序时(以及当我在浏览器本身中输入地址时),我收到消息: HTTP 错误 404.0 - 未找到详细的错误信息是:
Most likely causes:最可能的原因:
But if I run the app in the console via dotnet Testapp.dll , then it is started and if I then enter the URL http://localhost:5000/api/test in the browser, then I get the data.但是,如果我通过dotnet Testapp.dll在控制台中运行该应用程序,那么它就会启动,然后如果我在浏览器中输入 URL http://localhost:5000/api/test,我就会得到数据。
So it can only be that something has gone wrong with the IIS App setup.所以只能是IIS App设置出了问题。 By the way I also have ASP.NET Core 7.0 Runtime (v7.0.1) - Windows Hosting Bundle installed.
顺便说一下,我还安装了ASP.NET Core 7.0 Runtime (v7.0.1) - Windows Hosting Bundle 。 When setting up the app on IIS I used the following guide: http://www.technical-recipes.com/2018/running-asp-net-web-api-services-in-iis/
在 IIS 上设置应用程序时,我使用了以下指南: http ://www.technical-recipes.com/2018/running-asp-net-web-api-services-in-iis/
Can anyone help me with any suggestions?谁能帮我提出任何建议?
Thanks谢谢
EDIT编辑
Following Lex's suggestion (see his comment below), I installed the Jexus Manager software and ran diagnostics.按照 Lex 的建议(请参阅下面他的评论),我安装了 Jexus Manager 软件并运行了诊断程序。 Here is the report:
这是报告:
System Time: 15.12.2022 10:18:45 Processor Architecture: AMD64 OS: Microsoft Windows NT 10.0.17763.0 Server Type: IIS系统时间:15.12.2022 10:18:45 处理器架构:AMD64 操作系统:Microsoft Windows NT 10.0.17763.0 服务器类型:IIS
Scan 28 installed module(s).扫描 28 个已安装的模块。 ASP.NET Core module version 2 is installed for .NET Core 3.1 and above: C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll (17.0.22323.1).
.NET Core 3.1 及更高版本安装了 ASP.NET Core 模块版本 2:C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll (17.0.22323.1)。
EDIT 2编辑 2
I am getting a little closer to the issue.我离这个问题越来越近了。 The fundamental error was that I used the app files from the release folder and not from Publish!
根本错误是我使用了发布文件夹中的应用程序文件,而不是发布文件夹中的应用程序文件!
I have now copied the app correctly and when I start the app in IIS, browser opens and I can request the data via the Api link, So locally on the server it works.我现在已经正确复制了该应用程序,当我在 IIS 中启动该应用程序时,浏览器打开,我可以通过 Api 链接请求数据,因此它在服务器本地工作。 the problem I have now is that it does not work from external: I get the message:
我现在遇到的问题是它不能从外部工作:我收到消息:
ERR_CONNECTION_TIMED_OUT ERR_CONNECTION_TIMED_OUT
The message also appears in the MAUI application which should use this web api: A connection attempt failed because the connected party did not respond properly after a period of time, or established connection failed because connected host has failed to respond.该消息还出现在应该使用此 Web API 的 MAUI 应用程序中:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机没有响应。 (api.website.com:64500)
(api.website.com:64500)
I started Diagnostic Tool again and I get the following output:我再次启动诊断工具,得到以下输出:
IMPORTANT: This report might contain confidential information.重要提示:本报告可能包含机密信息。 Mask such before sharing with others.
在与他人分享之前掩盖这些。
System Time: 15.12.2022 10:33:27系统时间:15.12.2022 10:33:27
Processor Architecture: AMD64处理器架构:AMD64
OS: Microsoft Windows NT 10.0.17763.0操作系统:Microsoft Windows NT 10.0.17763.0
Server Type: IIS服务器类型:IIS
Scan 28 installed module(s).扫描 28 个已安装的模块。
ASP.NET Core module version 2 is installed for .NET Core 3.1 and above: C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll (17.0.22323.1). .NET Core 3.1 及更高版本安装了 ASP.NET Core 模块版本 2:C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll (17.0.22323.1)。
Scan 45 registered handler(s).扫描 45 个注册处理程序。
Now it works.现在可以了。 If someone else has similar problems (Minimal Api application under NET 7 on IIS), then here are a few tips:
如果其他人有类似的问题(IIS上NET 7下的Minimal Api application),那么这里有几个提示:
So, hope I have not missed anything.所以,希望我没有错过任何东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.