简体   繁体   English

启动 IIS Express cmd 而不是 VS2022

[英]Starting IIS Express cmd rather than VS2022

The ASP.Net Core 6 Web Api runs under IIS Express via VS2022 just fine and allows me to load the swagger page (http://localhost:8084/swagger/index.html): 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

When running it from the cmdline:从 cmdline 运行它时:

"C:\Program Files (x86)\IIS Express\iisexpress" /config:applicationhost.config /site:TheWebApi

Swagger does not load returning a HTTP 500: 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's blog How Visual Studio Launches IIS Express to Debug ASP.NET Core Apps was very helpful in me gaining more information on what is going on. Lex Li 的博客How Visual Studio Launches IIS Express to Debug ASP.NET Core Apps对我获得有关正在发生的事情的更多信息非常有帮助。 Clearly, VS2022 is doing some magic to make things run in debug mode.显然,VS2022 正在施展魔法,让事情在调试模式下运行。 In my case, I am trying to get a desktop app to launch the ASP.Net Core 6 application, so debugging is not a concern.就我而言,我正在尝试获取桌面应用程序来启动 ASP.Net Core 6 应用程序,因此调试不是问题。 When I looked into the event log, I found what might be the problem, but don't know the solution:当我查看事件日志时,我发现可能是什么问题,但不知道解决方案:

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'

The problem is the application is.Net 6, not.Net 5. It was originally.Net 5, but it has been upgraded to.Net 6. This has me thinking...问题是应用程序是.Net 6,不是.Net 5。它最初是.Net 5,但已经升级到.Net 6。这让我想到了......

I did just create a new.Net WebApi project (WebApplication2) to compare the applicationhost.conf generated vs the real project (WebApplication1).我只是创建了一个新的 .Net WebApi 项目 (WebApplication2) 来比较生成的 applicationhost.conf 与真实项目 (WebApplication1)。 The WebApplication1 has the following section which was not in WebApplicaiton2: 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>

Since I don't want Visual Studio 2022 to be taken into account, should physicalPath="C:\Users\sam\source\repos\WebApplication1\bin\Debug.net6.0"?由于我不想考虑 Visual Studio 2022,因此 physicalPath="C:\Users\sam\source\repos\WebApplication1\bin\Debug.net6.0" 应该吗?

In my particular case, there is a desktop application that is managing the execution of the ASP.Net Core 6 Web API application in question.在我的特殊情况下,有一个桌面应用程序正在管理所讨论的 ASP.Net Core 6 Web API 应用程序的执行。 It turns out that it is possible to publish the ASP.Net Core 6 Web API application into a single EXE, which is called a Self-contained deployment .事实证明,可以将 ASP.Net Core 6 Web API 应用程序发布到单个 EXE 中,这称为Self-contained deployment This is what I needed.这就是我需要的。

暂无
暂无

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

相关问题 Swagger / Swashbuckle在IIS Express中有效,但在IIS中无效 - Swagger / Swashbuckle works in IIS Express but not IIS 使用基于katana-owin的web api运行的Swashbuckle不能与IIS一起使用,但可以与IIS Express一起使用 - Swashbuckle running with katana-owin based web api doesnt work with IIS but works with IIS Express ASP.NET CORE 5.0 Web API 在 IIS Express 上工作,但在 IIS 10 上托管时给出 404 - ASP.NET CORE 5.0 Web API works on IIS Express but gives 404 when hosted on IIS 10 使用Swagger跨IIS Express管理微服务体系结构 - Using Swagger to Manage Microservice Architecture Across IIS Express 有没有办法从 json 或 yml 而不是 class 中引用 swagger @ApiResponse 中的响应? - Is there a way to reference response in swagger @ApiResponse from json or yml rather than a class? SwaggerUI 导致 Index.html startup side effect on IIS express in Blazor App - SwaggerUI causes Index.html startup side effect on IIS express in Blazor App 如何在 Swagger 响应中指定特定参数而不是使用“allOf”? - How do I specify specific parameters in a Swagger response rather than use `allOf`? Swagger UI 将绑定到单个操作参数的多个标头作为单个 json 对象发送,而不是作为多个标头 - Swagger UI sends multiple headers bound to a single action parameter as a single json object, rather than as multiple headers 如何让 Swagger-UI 使用 YAML/JSON 而不必在我的 REST 控制器上添加注释? - How do I make Swagger-UI use a YAML/JSON rather than having to put annotations on my REST controller? 我应该如何获得 json 引用而不是获得它引用 - 不应该有额外的属性附加属性:定义 - how should i get the json references inline rather than getting it references - should NOT have additional properties additionalProperty: definitions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM