IIS 6 Web通过ASP.Net很好地在IIS下运行,并允许我加载swagger页面(http://localhost:8084/swagger/index.html):
#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: YYYY-DD-MM 17:49:22
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
YYYY-DD-MM 17:49:22 ::1 GET /_framework/aspnetcore-browser-refresh.js - 8084 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/107.0.0.0+Safari/537.36 http://localhost:8084/swagger/index.html 200 0 0 6
YYYY-DD-MM 17:49:22 ::1 GET /swagger/index.html - 8084 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/107.0.0.0+Safari/537.36 - 200 0 0 3664
YYYY-DD-MM 17:49:22 ::1 GET /_vs/browserLink - 8084 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/107.0.0.0+Safari/537.36 http://localhost:8084/swagger/index.html 200 0 0 59
YYYY-DD-MM 17:49:22 ::1 GET /swagger/v1/swagger.json - 8084 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/107.0.0.0+Safari/537.36 http://localhost:8084/swagger/index.html 200 0 0 149
从cmdline运行它时:
"C:\Program Files (x86)\IIS Express\iisexpress" /config:applicationhost.config /site:TheWebApi
Swagger不加载返回HTTP 500的内容:
#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2022-11-19 17:54:41
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2022-11-19 17:54:41 ::1 GET /swagger/index.html - 8084 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/107.0.0.0+Safari/537.36 - 500 0 574 8
2022-11-19 17:54:41 ::1 GET /favicon.ico - 8084 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/107.0.0.0+Safari/537.36 http://localhost:8084/swagger/index.html 500 0 574 0
Lex的博客Visual如何启动IIS来调试ASP.NET核心应用程序对我获得更多关于正在发生的事情的信息非常有帮助。显然,VS2022正在做一些神奇的工作来使事情在调试模式下运行。在我的例子中,我试图获得一个桌面应用程序来启动ASP.Net核心6应用程序,所以调试不是一个问题。当我查看事件日志时,我发现了可能的问题所在,但不知道解决方案:
Application 'C:\Users\sam\source\repos\WebApplication1\' failed to start. Exception message:
Executable was not found at 'C:\Users\sam\source\repos\WebApplication1\bin\Debug\net5.0\WebApplication1.exe'
问题是应用程序是.Net 6,而不是.Net 5。它最初是.Net 5,但它已经升级到.Net 6。
我刚刚创建了一个新的.Net WebApi项目(WebApplication2)来比较生成的applicationhost.conf和真实的项目(WebApplication1)。WebApplication1有以下不在WebApplicaiton2中的部分:
<site name="WebApplication1" id="2">
<application path="/" applicationPool="WebApplication1 AppPool">
<virtualDirectory path="/" physicalPath="C:\Users\sam\source\repos\WebApplication1" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:8084:localhost" />
</bindings>
</site>
由于我不希望将VisualStudio2022考虑在内,所以physicalPath="C:\Users\sam\source\repos\WebApplication1\bin\Debug\net6.0"?应该
发布于 2022-12-04 19:21:32
在我的特定案例中,有一个桌面应用程序正在管理ASP.Net Core6WebAPI应用程序的执行。事实证明,可以将ASP.Net Core6WebAPI应用程序发布到一个名为自给式部署的EXE中。这就是我所需要的。
https://stackoverflow.com/questions/74502423
复制相似问题