在IIS中托管ASP.NET Core 9 Web API时出现404.0错误的原因?
使用.NET 9和IIS 10托管ASP.NET Core 9 Web API时遇到问题,自建项目与VS 2022预构建的WeatherForecast项目均出现相同异常。
已完成操作
- 安装ASP.NET Core 9托管包
- 将VS发布到文件夹的含.dll文件部署到应用池用户拥有完全权限的目录
- 在IIS中创建网站并绑定到端口5000
问题现象
直接运行命令 dotnet apitestapp.dll 时API正常,浏览器访问 http://localhost:5000/weatherforecast 可获取输出;但通过IIS访问该URL时,出现IIS 404.0错误页面,错误详情如下:
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://localhost:5000/weatherforecast
Physical Path C:\Program Files (x86)\MyApp\REST Interface\test\weatherforecast
Logon Method Anonymous
Logon User Anonymous
使用第三方工具Jexus Manager生成的网站运行报告显示:
System Time: 2/13/2025 2:07:08 AM
Processor Architecture: AMD64
OS: Microsoft Windows NT 10.0.20348.0
Server Type: IISScan 30 installed module(s).
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 (19.0.24346.1).Scan 46 registered handler(s).
No valid ASP.NET Core handler is registered for this web site.
To run ASP.NET Core on IIS, please refer to https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index for more details.
已查阅相关部署配置步骤,请问遗漏了什么?
内容的提问来源于stack exchange,提问作者NeartCarp

