繁体   English   中英

启动 IIS Express cmd 而不是 VS2022

[英]Starting IIS Express cmd rather than VS2022

ASP.Net Core 6 Web Api 通过 VS2022 在 IIS Express 下正常运行,并允许我加载 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 Li 的博客How Visual Studio Launches IIS Express to Debug ASP.NET Core Apps对我获得有关正在发生的事情的更多信息非常有帮助。 显然,VS2022 正在施展魔法,让事情在调试模式下运行。 就我而言,我正在尝试获取桌面应用程序来启动 ASP.Net Core 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>

由于我不想考虑 Visual Studio 2022,因此 physicalPath="C:\Users\sam\source\repos\WebApplication1\bin\Debug.net6.0" 应该吗?

在我的特殊情况下,有一个桌面应用程序正在管理所讨论的 ASP.Net Core 6 Web API 应用程序的执行。 事实证明,可以将 ASP.Net Core 6 Web API 应用程序发布到单个 EXE 中,这称为Self-contained deployment 这就是我需要的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM