首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >启动IIS cmd而不是VS2022

启动IIS cmd而不是VS2022
EN

Stack Overflow用户
提问于 2022-11-19 18:07:27
回答 1查看 26关注 0票数 0

IIS 6 Web通过ASP.Net很好地在IIS下运行,并允许我加载swagger页面(http://localhost:8084/swagger/index.html):

代码语言:javascript
运行
复制
#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运行它时:

代码语言:javascript
运行
复制
"C:\Program Files (x86)\IIS Express\iisexpress" /config:applicationhost.config /site:TheWebApi

Swagger不加载返回HTTP 500的内容:

代码语言:javascript
运行
复制
#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应用程序,所以调试不是一个问题。当我查看事件日志时,我发现了可能的问题所在,但不知道解决方案:

代码语言:javascript
运行
复制
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中的部分:

代码语言:javascript
运行
复制
<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"?应该

EN

回答 1

Stack Overflow用户

发布于 2022-12-04 19:21:32

在我的特定案例中,有一个桌面应用程序正在管理ASP.Net Core6WebAPI应用程序的执行。事实证明,可以将ASP.Net Core6WebAPI应用程序发布到一个名为自给式部署的EXE中。这就是我所需要的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74502423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档