简体   繁体   English

ASP.NET 核心同时构建 IIS Express 和 Kestrel?

[英]ASP.NET core builds both IIS Express and Kestrel?

I am using ASP.NET Core with VS 2017. I am wondering if the applications when being built create both IIS Express and Kestrel ?我在 VS 2017 中使用 ASP.NET Core。我想知道构建时应用程序是否同时创建IIS Express and Kestrel Or just one of them?或者只是其中之一? I am talking just locally .我只是在本地谈论。

If you look your launchSettings.json file under Properties section.如果您查看“属性”部分下的launchSettings.json文件。 you'll see your launch profiles.您会看到您的启动配置文件。 For example:例如:

...
"profiles": {
"IIS Express": {
  "commandName": "IISExpress",
  "launchBrowser": true,
  "launchUrl": "https://localhost:44376/",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  }
},
"WebApplication1": {
  "commandName": "Project",
  "launchBrowser": true,
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  },
  "applicationUrl": "http://localhost:50768/"
}
}
...

These profiles specify how your app will run with what settings and environment variables.这些配置文件指定您的应用程序将如何使用哪些设置和环境变量运行。 You can have as many launch profiles as you want with different settings.您可以使用不同的设置拥有任意数量的启动配置文件。

The commandName can have one these: commandName可以有以下之一:

  • IIS信息系统

  • IISExpress IIS快递

  • Project (which uses Kestrel)项目(使用 Kestrel)

You can change your launching profile with the dropdown next to the Run button in VS or with the following command:您可以使用 VS 中“运行”按钮旁边的下拉菜单或使用以下命令来更改您的启动配置文件:

dotnet run --lauch-profile <profile_name>

Kestrel is not recommended for production but is OK for development.不建议将 Kestrel 用于生产,但可以用于开发。 Even if you choose IIS or IISExpress , Kestrel will always be used (unless you use HTTP.sys which is only available for Windows).即使您选择IISIISExpress ,也会始终使用 Kestrel(除非您使用仅适用于 Windows 的 HTTP.sys)。 So no matter what web server you use in production (IIS, nginx, Apache) or in development, they will always pass the request to Kestrel after doing their job on the request.因此,无论您在生产(IIS、nginx、Apache)或开发中使用什么 Web 服务器,它们都会在完成请求后将请求传递给 Kestrel。

Your question is not clear at all.你的问题根本不清楚。 Kestrel is always used.红隼总是被使用。 IIS Express acts as a reverse proxy for Krestrel. IIS Express 充当 Krestrel 的反向代理。 However, nothing is "created" in this regard.然而,在这方面没有什么是“创造”的。 When the core app is built, you simply end up with the app itself.构建核心应用程序后,您只需完成应用程序本身即可。 The functionality to host it is external.托管它的功能是外部的。 You can build as a self-hosted application, in which case you'll get an executable instead of a DLL.可以构建为自托管应用程序,在这种情况下,您将获得可执行文件而不是 DLL。 However, that's never going to be part of debugging or running locally in Visual Studio: your app will always be built as a DLL.但是,这永远不会成为调试的一部分或在 Visual Studio 中本地运行:您的应用程序将始终构建为 DLL。

In older revisions of Visual Studio 2017, it used to be possible to run/debug your app as either self-hosted or in IIS Express, if that's what you're talking about.在 Visual Studio 2017 的旧版本中,过去可以将您的应用程序作为自托管或在 IIS Express 中运行/调试,如果这就是您所说的。 However, that option has since been removed.但是,此选项已被删除。 Run/debug always uses IIS Express, now.运行/调试现在总是使用 IIS Express。

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

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