ASP.NET Core 模块ASP.NET Core Module

作者:Tom DykstraRick StrahlChris RossRick AndersonSourabh ShirhattiJustin KotalikLuke LathamBy Tom Dykstra, Rick Strahl, Chris Ross, Rick Anderson, Sourabh Shirhatti, Justin Kotalik, and Luke Latham

ASP.NET Core 模块是插入 IIS 管道的本机 IIS 模块,用于:The ASP.NET Core Module is a native IIS module that plugs into the IIS pipeline to either:

受支持的 Windows 版本:Supported Windows versions:

  • Windows 7 或更高版本Windows 7 or later
  • Windows Server 2008 R2 或更高版本Windows Server 2008 R2 or later

在进程内托管时,该模块会使用 IIS 进程内服务器实现,即 IIS HTTP 服务器 (IISHttpServer)。When hosting in-process, the module uses an in-process server implementation for IIS, called IIS HTTP Server (IISHttpServer).

在进程外托管时,该模块仅适用于 Kestrel。When hosting out-of-process, the module only works with Kestrel. 该模块与 HTTP.sys 不兼容。The module is incompatible with HTTP.sys.

托管模型Hosting models

进程内托管模型In-process hosting model

若要配置用于进程内托管的应用,请将 <AspNetCoreHostingModel> 属性添加到值为 InProcess(进程外托管使用 OutOfProcess 进行设置)的应用项目文件:To configure an app for in-process hosting, add the <AspNetCoreHostingModel> property to the app's project file with a value of InProcess (out-of-process hosting is set with OutOfProcess):

<PropertyGroup>
  <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>

定目标到 .NET Framework 的 ASP.NET Core 应用不支持进程内托管模型。The in-process hosting model isn't supported for ASP.NET Core apps that target the .NET Framework.

如果文件中不存在 <AspNetCoreHostingModel> 属性,则默认值为 OutOfProcessIf the <AspNetCoreHostingModel> property isn't present in the file, the default value is OutOfProcess.

在进程内托管时,将应用以下特征:The following characteristics apply when hosting in-process:

  • 使用 IIS HTTP 服务器 (IISHttpServer) 而不是 Kestrel 服务器。IIS HTTP Server (IISHttpServer) is used instead of Kestrel server. 在进程内,CreateDefaultBuilder 调用 UseIIS 以执行以下操作:For in-process, CreateDefaultBuilder calls UseIIS to:

    • 注册 IISHttpServerRegister the IISHttpServer.
    • 在 ASP.NET Core 模块后运行时,配置服务器应侦听的端口和基本路径。Configure the port and base path the server should listen on when running behind the ASP.NET Core Module.
    • 配置主机以捕获启动错误。Configure the host to capture startup errors.
  • requestTimeout 属性不适用于进程内托管。The requestTimeout attribute doesn't apply to in-process hosting.

  • 不支持在应用之间共享应用池。Sharing an app pool among apps isn't supported. 每个应用使用一个应用池。Use one app pool per app.

  • 使用 Web 部署或手动将 app_offline.htm 文件置于部署中时,如果有已打开的连接,则应用可能不会立即关闭。When using Web Deploy or manually placing an app_offline.htm file in the deployment, the app might not shut down immediately if there's an open connection. 例如,WebSocket 连接可能会延迟应用关闭。For example, a websocket connection may delay app shut down.

  • 应用和已安装的运行时(x64 或 x86)的体系结构(位数)必须与应用池的体系结构匹配。The architecture (bitness) of the app and installed runtime (x64 or x86) must match the architecture of the app pool.

  • 如果使用 WebHostBuilder(而不是使用 CreateDefaultBuilder)手动设置应用的主机,并且应用曾经直接在 Kestrel 服务器上运行(自托管),则先调用 UseKestrel,再调用 UseIISIntegrationIf setting up the app's host manually with WebHostBuilder (not using CreateDefaultBuilder) and the app is ever run directly on the Kestrel server (self-hosted), call UseKestrel before calling UseIISIntegration. 如果顺序颠倒,主机将无法启动。If the order is reversed, the host fails to start.

  • 检测到客户端连接断开。Client disconnects are detected. 客户端连接断开时,HttpContext.RequestAborted 取消标记将会取消。The HttpContext.RequestAborted cancellation token is cancelled when the client disconnects.

  • 在 ASP.NET Core 2.2.1 或早期版本中,GetCurrentDirectory 会返回 IIS 启动的进程的工作目录而非应用目录(例如,对于 w3wp.exe,是 C:\Windows\System32\inetsrv )。In ASP.NET Core 2.2.1 or earlier, GetCurrentDirectory returns the worker directory of the process started by IIS rather than the app's directory (for example, C:\Windows\System32\inetsrv for w3wp.exe).

    对于设置应用的当前目录的示例代码,请参阅 CurrentDirectoryHelpers 类For sample code that sets the app's current directory, see the CurrentDirectoryHelpers class. 调用 SetCurrentDirectory 方法。Call the SetCurrentDirectory method. 后续 GetCurrentDirectory 调用提供应用的目录。Subsequent calls to GetCurrentDirectory provide the app's directory.

  • 在进程内托管时,不会在内部调用 AuthenticateAsync 来初始化用户。When hosting in-process, AuthenticateAsync isn't called internally to initialize a user. 因此,默认情况下不激活每次身份验证后用于转换声明的 IClaimsTransformation 实现。Therefore, an IClaimsTransformation implementation used to transform claims after every authentication isn't activated by default. 使用 IClaimsTransformation 实现转换声明时,请调用 AddAuthentication 以添加身份验证服务:When transforming claims with an IClaimsTransformation implementation, call AddAuthentication to add authentication services:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddTransient<IClaimsTransformation, ClaimsTransformer>();
        services.AddAuthentication(IISServerDefaults.AuthenticationScheme);
    }
    
    public void Configure(IApplicationBuilder app)
    {
        app.UseAuthentication();
    }
    

进程外托管模型Out-of-process hosting model

若要配置进程外托管应用,请在项目文件中使用以下方法之一:To configure an app for out-of-process hosting, use either of the following approaches in the project file:

  • 不指定 <AspNetCoreHostingModel> 属性。Don't specify the <AspNetCoreHostingModel> property. 如果文件中不存在 <AspNetCoreHostingModel> 属性,则默认值为 OutOfProcessIf the <AspNetCoreHostingModel> property isn't present in the file, the default value is OutOfProcess.
  • <AspNetCoreHostingModel> 属性的值设为 OutOfProcess(进程内托管设为 InProcess):Set the value of the <AspNetCoreHostingModel> property to OutOfProcess (in-process hosting is set with InProcess):
<PropertyGroup>
  <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>

使用 Kestrel 服务器,而不是 IIS HTTP 服务器 (IISHttpServer)。Kestrel server is used instead of IIS HTTP Server (IISHttpServer).

在进程外,CreateDefaultBuilder 调用 UseIISIntegration 以执行以下操作:For out-of-process, CreateDefaultBuilder calls UseIISIntegration to:

  • 在 ASP.NET Core 模块后运行时,配置服务器应侦听的端口和基本路径。Configure the port and base path the server should listen on when running behind the ASP.NET Core Module.
  • 配置主机以捕获启动错误。Configure the host to capture startup errors.

托管模型更改Hosting model changes

如果 hostingModel 设置在 web.config 文件中被更改(如 web.config 的配置部分中所述),则该模块会再循环 IIS 工作进程。If the hostingModel setting is changed in the web.config file (explained in the Configuration with web.config section), the module recycles the worker process for IIS.

对于 IIS Express,该模块不会再循环工作进程,但改为触发当前 IIS Express 进程的正常关闭。For IIS Express, the module doesn't recycle the worker process but instead triggers a graceful shutdown of the current IIS Express process. 应用的下一个请求会生成新的 IIS Express 进程。The next request to the app spawns a new IIS Express process.

进程名Process name

Process.GetCurrentProcess().ProcessName 报告 w3wp/iisexpress(进程内)或 dotnet(进程外)。Process.GetCurrentProcess().ProcessName reports w3wp/iisexpress (in-process) or dotnet (out-of-process).

ASP.NET Core 模块是插入 IIS 管道的本机 IIS 模块,用于将 Web 请求转发到后端 ASP.NET Core 应用。The ASP.NET Core Module is a native IIS module that plugs into the IIS pipeline to forward web requests to backend ASP.NET Core apps.

受支持的 Windows 版本:Supported Windows versions:

  • Windows 7 或更高版本Windows 7 or later
  • Windows Server 2008 R2 或更高版本Windows Server 2008 R2 or later

该模块仅适用于 Kestrel。The module only works with Kestrel. 该模块与 HTTP.sys 不兼容。The module is incompatible with HTTP.sys.

由于 ASP.NET Core 应用在独立于 IIS 辅助进程的进程中运行,因此该模块还处理进程管理。Because ASP.NET Core apps run in a process separate from the IIS worker process, the module also handles process management. 该模块在第一个请求到达时启动 ASP.NET Core 应用的进程,并在应用崩溃时重新启动该应用。The module starts the process for the ASP.NET Core app when the first request arrives and restarts the app if it crashes. 这基本上与在 Windows 进程激活服务 (WAS) 托管的 IIS 中在进程内运行的 ASP.NET 4.x 应用中出现的行为相同。This is essentially the same behavior as seen with ASP.NET 4.x apps that run in-process in IIS that are managed by the Windows Process Activation Service (WAS).

下图说明了 IIS、ASP.NET Core 模块和应用之间的关系:The following diagram illustrates the relationship between IIS, the ASP.NET Core Module, and an app:

ASP.NET Core 模块

请求从 Web 到达内核模式 HTTP.sys 驱动程序。Requests arrive from the web to the kernel-mode HTTP.sys driver. 驱动程序将请求路由到网站的配置端口上的 IIS,通常为 80 (HTTP) 或 443 (HTTPS)。The driver routes the requests to IIS on the website's configured port, usually 80 (HTTP) or 443 (HTTPS). 该模块将该请求转发到应用的随机端口(非端口 80/443)上的 Kestrel。The module forwards the requests to Kestrel on a random port for the app, which isn't port 80 or 443.

该模块在启动时通过环境变量指定端口,IIS 集成中间件将服务器配置为侦听 http://localhost:{port}The module specifies the port via an environment variable at startup, and the IIS Integration Middleware configures the server to listen on http://localhost:{port}. 执行其他检查,拒绝不是来自该模块的请求。Additional checks are performed, and requests that don't originate from the module are rejected. 该模块不支持 HTTPS 转发,因此即使请求由 IIS 通过 HTTPS 接收,它们还是通过 HTTP 转发。The module doesn't support HTTPS forwarding, so requests are forwarded over HTTP even if received by IIS over HTTPS.

Kestrel 从模块获取请求后,请求会被推送到 ASP.NET Core 中间件管道中。After Kestrel picks up the request from the module, the request is pushed into the ASP.NET Core middleware pipeline. 中间件管道处理该请求并将其作为 HttpContext 实例传递给应用的逻辑。The middleware pipeline handles the request and passes it on as an HttpContext instance to the app's logic. IIS 集成添加的中间件会将方案、远程 IP 和 pathbase 更新到帐户以将请求转发到 Kestrel。Middleware added by IIS Integration updates the scheme, remote IP, and pathbase to account for forwarding the request to Kestrel. 应用的响应传递回 IIS,IIS 将响应推送回发起请求的 HTTP 客户端。The app's response is passed back to IIS, which pushes it back out to the HTTP client that initiated the request.

许多本机模块(如 Windows 身份验证)仍处于活动状态。Many native modules, such as Windows Authentication, remain active. 要详细了解随 ASP.NET Core 模块活动的 IIS 模块,请参阅 IIS 模块与 ASP.NET CoreTo learn more about IIS modules active with the ASP.NET Core Module, see IIS 模块与 ASP.NET Core.

ASP.NET Core 模块还可以:The ASP.NET Core Module can also:

  • 为工作进程设置环境变量。Set environment variables for the worker process.
  • 将 stdout 输出记录到文件存储器,以解决启动问题。Log stdout output to file storage for troubleshooting startup issues.
  • 转发 Windows 身份验证令牌。Forward Windows authentication tokens.

如何安装和使用 ASP.NET Core 模块How to install and use the ASP.NET Core Module

有关如何安装 ASP.NET Core 模块的说明,请参阅安装 .NET Core 托管捆绑包For instructions on how to install the ASP.NET Core Module, see Install the .NET Core Hosting Bundle.

web.config 的配置Configuration with web.config

在站点的 web.config 文件中使用 system.webServer 节点的 aspNetCore 部分配置 ASP.NET Core 模块。The ASP.NET Core Module is configured with the aspNetCore section of the system.webServer node in the site's web.config file.

以下 web.config 文件发布用于依赖框架的部署,并配置 ASP.NET Core 模块以处理站点请求:The following web.config file is published for a framework-dependent deployment and configures the ASP.NET Core Module to handle site requests:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet"
                  arguments=".\MyApp.dll"
                  stdoutLogEnabled="false"
                  stdoutLogFile=".\logs\stdout"
                  hostingModel="InProcess" />
    </system.webServer>
  </location>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet"
                arguments=".\MyApp.dll"
                stdoutLogEnabled="false"
                stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

以下 web.config 发布用于独立部署The following web.config is published for a self-contained deployment:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\MyApp.exe"
                  stdoutLogEnabled="false"
                  stdoutLogFile=".\logs\stdout"
                  hostingModel="InProcess" />
    </system.webServer>
  </location>
</configuration>

InheritInChildApplications 属性设置为 false,表示 <> 元素中指定的设置不会由驻留在应用子目录中的应用继承。The InheritInChildApplications property is set to false to indicate that the settings specified within the <location> element aren't inherited by apps that reside in a subdirectory of the app.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\MyApp.exe"
                stdoutLogEnabled="false"
                stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

将应用部署为 Azure 应用服务时,stdoutLogFile 路径将设置为 \\?\%home%\LogFiles\stdoutWhen an app is deployed to Azure App Service, the stdoutLogFile path is set to \\?\%home%\LogFiles\stdout. 该路径会将 stdout 日志保存到 LogFiles 文件夹,该文件夹是由服务自动创建的位置。The path saves stdout logs to the LogFiles folder, which is a location automatically created by the service.

有关 IIS 子应用程序配置的信息,请参阅使用 IIS 在 Windows 上托管 ASP.NET CoreFor information on IIS sub-application configuration, see 使用 IIS 在 Windows 上托管 ASP.NET Core.

aspNetCore 元素的属性Attributes of the aspNetCore element

特性Attribute 说明Description 默认Default
arguments

可选的字符串属性。Optional string attribute.

processPath 中指定的可执行文件的参数。Arguments to the executable specified in processPath.

disableStartUpErrorPage

可选布尔属性。Optional Boolean attribute.

如果为 true,将禁止显示“502.5 - 进程失败” 页面,而会优先显示 web.config 中配置的 502 状态代码页面。If true, the 502.5 - Process Failure page is suppressed, and the 502 status code page configured in the web.config takes precedence.

false
forwardWindowsAuthToken

可选布尔属性。Optional Boolean attribute.

如果为 true,会将令牌作为每个请求的标头“MS-ASPNETCORE-WINAUTHTOKEN”,转发到在 %ASPNETCORE_PORT% 上侦听的子进程。If true, the token is forwarded to the child process listening on %ASPNETCORE_PORT% as a header 'MS-ASPNETCORE-WINAUTHTOKEN' per request. 该进程负责在每个请求的此令牌上调用 CloseHandle。It's the responsibility of that process to call CloseHandle on this token per request.

true
hostingModel

可选的字符串属性。Optional string attribute.

将托管模型指定为进程内 (InProcess) 或进程外 (OutOfProcess)。Specifies the hosting model as in-process (InProcess) or out-of-process (OutOfProcess).

OutOfProcess
processesPerApplication

可选的整数属性。Optional integer attribute.

指定每个应用均可启动的 processPath 设置中指定的进程的实例数。Specifies the number of instances of the process specified in the processPath setting that can be spun up per app.

†对于进程内托管,值限制为 1†For in-process hosting, the value is limited to 1.

不建议设置 processesPerApplicationSetting processesPerApplication is discouraged. 将来的版本将删除此属性。This attribute will be removed in a future release.

默认值:1Default: 1
最小值:1Min: 1
最大值:100Max: 100
processPath

必需的字符串属性。Required string attribute.

为 HTTP 请求启动进程侦听的可执行文件的路径。Path to the executable that launches a process listening for HTTP requests. 支持相对路径。Relative paths are supported. 如果路径以 . 开头,则该路径被视为与站点根目录相对。If the path begins with ., the path is considered to be relative to the site root.

rapidFailsPerMinute

可选的整数属性。Optional integer attribute.

指定允许 processPath 中指定的进程每分钟崩溃的次数。Specifies the number of times the process specified in processPath is allowed to crash per minute. 如果超出了此限制,模块将在剩余分钟数内停止启动该进程。If this limit is exceeded, the module stops launching the process for the remainder of the minute.

不支持进程内托管。Not supported with in-process hosting.

默认值:10Default: 10
最小值:0Min: 0
最大值:100Max: 100
requestTimeout

可选的 timespan 属性。Optional timespan attribute.

指定 ASP.NET Core 模块等待来自 %ASPNETCORE_PORT% 上侦听的进程的响应的持续时间。Specifies the duration for which the ASP.NET Core Module waits for a response from the process listening on %ASPNETCORE_PORT%.

在 ASP.NET Core 2.1 或更高版本附带的 ASP.NET Core 模块版本中,使用小时数、分钟数和秒数指定 requestTimeoutIn versions of the ASP.NET Core Module that shipped with the release of ASP.NET Core 2.1 or later, the requestTimeout is specified in hours, minutes, and seconds.

不适用于进程内托管。Doesn't apply to in-process hosting. 对于进程内托管,该模块等待应用处理该请求。For in-process hosting, the module waits for the app to process the request.

此字符串的分钟段和秒钟段的有效值在 0-59 之间。Valid values for minutes and seconds segments of the string are in the range 0-59. 在分钟或秒钟值中使用“60” 会导致“500 - 内部服务器错误” 。Use of 60 in the value for minutes or seconds results in a 500 - Internal Server Error.

默认值:00:02:00Default: 00:02:00
最小值:00:00:00Min: 00:00:00
最大值:360:00:00Max: 360:00:00
shutdownTimeLimit

可选的整数属性。Optional integer attribute.

检测到 app_offline.htm 文件时,模块等待可执行文件正常关闭的持续时间(以秒为单位)。Duration in seconds that the module waits for the executable to gracefully shutdown when the app_offline.htm file is detected.

默认值:10Default: 10
最小值:0Min: 0
最大值:600Max: 600
startupTimeLimit

可选的整数属性。Optional integer attribute.

模块等待可执行文件启动端口上侦听的进程的持续时间(以秒为单位)。Duration in seconds that the module waits for the executable to start a process listening on the port. 如果超出了此时间限制,模块将终止该进程。If this time limit is exceeded, the module kills the process. 模块在收到新请求时尝试重新启动该进程,并在收到后续传入请求时继续尝试重新启动该进程,除非应用在上一回滚分钟内无法启动 rapidFailsPerMinute 次。The module attempts to relaunch the process when it receives a new request and continues to attempt to restart the process on subsequent incoming requests unless the app fails to start rapidFailsPerMinute number of times in the last rolling minute.

值 0(零) 不被视为无限超时。A value of 0 (zero) is not considered an infinite timeout.

默认值:120Default: 120
最小值:0Min: 0
最大值:3600Max: 3600
stdoutLogEnabled

可选布尔属性。Optional Boolean attribute.

如果为 true,processPath 中指定的 进程的 stdout 和 stderr 将重定向到 stdoutLogFile 中指定的文件。If true, stdout and stderr for the process specified in processPath are redirected to the file specified in stdoutLogFile.

false
stdoutLogFile

可选的字符串属性。Optional string attribute.

指定在其中记录 processPath 中指定进程的 stdout 和 stderr 的相对路径或绝对路径。Specifies the relative or absolute file path for which stdout and stderr from the process specified in processPath are logged. 相对路径与站点根目录相对。Relative paths are relative to the root of the site. . 开头的任何路径均与站点根目录相对,所有其他路径被视为绝对路径。Any path starting with . are relative to the site root and all other paths are treated as absolute paths. 创建日志文件时,模块会创建路径中提供的所有文件夹。Any folders provided in the path are created by the module when the log file is created. 使用下划线分隔符,将时间戳、进程 ID 和文件扩展名 (.log ) 添加到 stdoutLogFile 路径的最后一段。Using underscore delimiters, a timestamp, process ID, and file extension (.log) are added to the last segment of the stdoutLogFile path. 如果 .\logs\stdout 作为值提供,则在示例 stdout 日志使用进程 ID 1934 于 2018 年 2 月 5 日 19:41:32 保存时,将在 logs 文件夹中保存为 stdout_20180205194132_1934.log 。If .\logs\stdout is supplied as a value, an example stdout log is saved as stdout_20180205194132_1934.log in the logs folder when saved on 2/5/2018 at 19:41:32 with a process ID of 1934.

aspnetcore-stdout
特性Attribute 说明Description 默认Default
arguments

可选的字符串属性。Optional string attribute.

processPath 中指定的可执行文件的参数。Arguments to the executable specified in processPath.

disableStartUpErrorPage

可选布尔属性。Optional Boolean attribute.

如果为 true,将禁止显示“502.5 - 进程失败” 页面,而会优先显示 web.config 中配置的 502 状态代码页面。If true, the 502.5 - Process Failure page is suppressed, and the 502 status code page configured in the web.config takes precedence.

false
forwardWindowsAuthToken

可选布尔属性。Optional Boolean attribute.

如果为 true,会将令牌作为每个请求的标头“MS-ASPNETCORE-WINAUTHTOKEN”,转发到在 %ASPNETCORE_PORT% 上侦听的子进程。If true, the token is forwarded to the child process listening on %ASPNETCORE_PORT% as a header 'MS-ASPNETCORE-WINAUTHTOKEN' per request. 该进程负责在每个请求的此令牌上调用 CloseHandle。It's the responsibility of that process to call CloseHandle on this token per request.

true
processesPerApplication

可选的整数属性。Optional integer attribute.

指定每个应用均可启动的 processPath 设置中指定的进程的实例数。Specifies the number of instances of the process specified in the processPath setting that can be spun up per app.

不建议设置 processesPerApplicationSetting processesPerApplication is discouraged. 将来的版本将删除此属性。This attribute will be removed in a future release.

默认值:1Default: 1
最小值:1Min: 1
最大值:100Max: 100
processPath

必需的字符串属性。Required string attribute.

为 HTTP 请求启动进程侦听的可执行文件的路径。Path to the executable that launches a process listening for HTTP requests. 支持相对路径。Relative paths are supported. 如果路径以 . 开头,则该路径被视为与站点根目录相对。If the path begins with ., the path is considered to be relative to the site root.

rapidFailsPerMinute

可选的整数属性。Optional integer attribute.

指定允许 processPath 中指定的进程每分钟崩溃的次数。Specifies the number of times the process specified in processPath is allowed to crash per minute. 如果超出了此限制,模块将在剩余分钟数内停止启动该进程。If this limit is exceeded, the module stops launching the process for the remainder of the minute.

默认值:10Default: 10
最小值:0Min: 0
最大值:100Max: 100
requestTimeout

可选的 timespan 属性。Optional timespan attribute.

指定 ASP.NET Core 模块等待来自 %ASPNETCORE_PORT% 上侦听的进程的响应的持续时间。Specifies the duration for which the ASP.NET Core Module waits for a response from the process listening on %ASPNETCORE_PORT%.

在 ASP.NET Core 2.1 或更高版本附带的 ASP.NET Core 模块版本中,使用小时数、分钟数和秒数指定 requestTimeoutIn versions of the ASP.NET Core Module that shipped with the release of ASP.NET Core 2.1 or later, the requestTimeout is specified in hours, minutes, and seconds.

默认值:00:02:00Default: 00:02:00
最小值:00:00:00Min: 00:00:00
最大值:360:00:00Max: 360:00:00
shutdownTimeLimit

可选的整数属性。Optional integer attribute.

检测到 app_offline.htm 文件时,模块等待可执行文件正常关闭的持续时间(以秒为单位)。Duration in seconds that the module waits for the executable to gracefully shutdown when the app_offline.htm file is detected.

默认值:10Default: 10
最小值:0Min: 0
最大值:600Max: 600
startupTimeLimit

可选的整数属性。Optional integer attribute.

模块等待可执行文件启动端口上侦听的进程的持续时间(以秒为单位)。Duration in seconds that the module waits for the executable to start a process listening on the port. 如果超出了此时间限制,模块将终止该进程。If this time limit is exceeded, the module kills the process. 模块在收到新请求时尝试重新启动该进程,并在收到后续传入请求时继续尝试重新启动该进程,除非应用在上一回滚分钟内无法启动 rapidFailsPerMinute 次。The module attempts to relaunch the process when it receives a new request and continues to attempt to restart the process on subsequent incoming requests unless the app fails to start rapidFailsPerMinute number of times in the last rolling minute.

值 0(零) 不被视为无限超时。A value of 0 (zero) is not considered an infinite timeout.

默认值:120Default: 120
最小值:0Min: 0
最大值:3600Max: 3600
stdoutLogEnabled

可选布尔属性。Optional Boolean attribute.

如果为 true,processPath 中指定的 进程的 stdout 和 stderr 将重定向到 stdoutLogFile 中指定的文件。If true, stdout and stderr for the process specified in processPath are redirected to the file specified in stdoutLogFile.

false
stdoutLogFile

可选的字符串属性。Optional string attribute.

指定在其中记录 processPath 中指定进程的 stdout 和 stderr 的相对路径或绝对路径。Specifies the relative or absolute file path for which stdout and stderr from the process specified in processPath are logged. 相对路径与站点根目录相对。Relative paths are relative to the root of the site. . 开头的任何路径均与站点根目录相对,所有其他路径被视为绝对路径。Any path starting with . are relative to the site root and all other paths are treated as absolute paths. 路径中提供的任何文件夹都必须存在,以便模块创建日志文件。Any folders provided in the path must exist in order for the module to create the log file. 使用下划线分隔符,将时间戳、进程 ID 和文件扩展名 (.log ) 添加到 stdoutLogFile 路径的最后一段。Using underscore delimiters, a timestamp, process ID, and file extension (.log) are added to the last segment of the stdoutLogFile path. 如果 .\logs\stdout 作为值提供,则在示例 stdout 日志使用进程 ID 1934 于 2018 年 2 月 5 日 19:41:32 保存时,将在 logs 文件夹中保存为 stdout_20180205194132_1934.log 。If .\logs\stdout is supplied as a value, an example stdout log is saved as stdout_20180205194132_1934.log in the logs folder when saved on 2/5/2018 at 19:41:32 with a process ID of 1934.

aspnetcore-stdout

设置环境变量Setting environment variables

可以为 processPath 属性中的进程指定环境变量。Environment variables can be specified for the process in the processPath attribute. 使用 <environmentVariables> 集合元素的 <environmentVariable> 子元素指定环境变量。Specify an environment variable with the <environmentVariable> child element of an <environmentVariables> collection element. 本部分中设置的环境变量优先于系统环境变量。Environment variables set in this section take precedence over system environment variables.

可以为 processPath 属性中的进程指定环境变量。Environment variables can be specified for the process in the processPath attribute. 使用 <environmentVariables> 集合元素的 <environmentVariable> 子元素指定环境变量。Specify an environment variable with the <environmentVariable> child element of an <environmentVariables> collection element.

警告

本部分中设置的环境变量与使用同一名称设置的系统环境变量冲突。Environment variables set in this section conflict with system environment variables set with the same name. 如果在 web.config 文件以及 Windows 中的系统级别中同时设置了环境变量,则 web.config 文件中的值将被追加到系统环境变量值(例如,ASPNETCORE_ENVIRONMENT: Development;Development),这将阻止应用启动。If an environment variable is set in both the web.config file and at the system level in Windows, the value from the web.config file becomes appended to the system environment variable value (for example, ASPNETCORE_ENVIRONMENT: Development;Development), which prevents the app from starting.

以下示例设置了两个环境变量。The following example sets two environment variables. ASPNETCORE_ENVIRONMENT 将应用的环境配置为 DevelopmentASPNETCORE_ENVIRONMENT configures the app's environment to Development. 开发人员可能会暂时在 web.config 文件中设置此值,以便在调试应用异常时强制加载开发人员异常页面A developer may temporarily set this value in the web.config file in order to force the Developer Exception Page to load when debugging an app exception. CONFIG_DIR 是用户定义的环境变量的一个示例,其中开发人员已写入可在启动时读取值的代码以便形成用于加载应用配置文件的路径。CONFIG_DIR is an example of a user-defined environment variable, where the developer has written code that reads the value on startup to form a path for loading the app's configuration file.

<aspNetCore processPath="dotnet"
      arguments=".\MyApp.dll"
      stdoutLogEnabled="false"
      stdoutLogFile="\\?\%home%\LogFiles\stdout"
      hostingModel="InProcess">
  <environmentVariables>
    <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
    <environmentVariable name="CONFIG_DIR" value="f:\application_config" />
  </environmentVariables>
</aspNetCore>
<aspNetCore processPath="dotnet"
      arguments=".\MyApp.dll"
      stdoutLogEnabled="false"
      stdoutLogFile="\\?\%home%\LogFiles\stdout">
  <environmentVariables>
    <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
    <environmentVariable name="CONFIG_DIR" value="f:\application_config" />
  </environmentVariables>
</aspNetCore>

备注

直接在 web.config 中设置环境的替代方法是将 <EnvironmentName> 属性包含在发布配置文件(.pubxml )或项目文件中。An alternative to setting the environment directly in web.config is to include the <EnvironmentName> property in the publish profile (.pubxml) or project file. 此方法在发布项目时设置 web.config 中的环境:This approach sets the environment in web.config when the project is published:

<PropertyGroup>
  <EnvironmentName>Development</EnvironmentName>
</PropertyGroup>

警告

在不可访问不受信任的网络(如 Internet)的暂存服务器和测试服务器上,仅将 ASPNETCORE_ENVIRONMENT 环境变量设置为 DevelopmentOnly set the ASPNETCORE_ENVIRONMENT environment variable to Development on staging and testing servers that aren't accessible to untrusted networks, such as the Internet.

app_offline.htmapp_offline.htm

如果在应用的根目录中检测到名为 “app_offline.htm” 的文件,ASP.NET Core 模块将尝试正常关闭应用并停止处理传入请求。If a file with the name app_offline.htm is detected in the root directory of an app, the ASP.NET Core Module attempts to gracefully shutdown the app and stop processing incoming requests. 如果应用在 shutdownTimeLimit 中定义的秒数之后仍在运行,ASP.NET Core 模块将终止正在运行的进程。If the app is still running after the number of seconds defined in shutdownTimeLimit, the ASP.NET Core Module kills the running process.

存在 app_offline.htm 文件时,ASP.NET Core 模块会通过发送回 app_offline.htm 文件的内容来响应请求。While the app_offline.htm file is present, the ASP.NET Core Module responds to requests by sending back the contents of the app_offline.htm file. 删除 app_offline.htm 文件后,下一个请求将启动应用。When the app_offline.htm file is removed, the next request starts the app.

使用进程外托管模型时,如果有已打开的连接,则应用可能不会立即关闭。When using the out-of-process hosting model, the app might not shut down immediately if there's an open connection. 例如,WebSocket 连接可能会延迟应用关闭。For example, a websocket connection may delay app shut down.

启动错误页面Start-up error page

进程内和进程外托管在无法启动应用时均会生成自定义错误页面。Both in-process and out-of-process hosting produce custom error pages when they fail to start the app.

如果 ASP.NET Core 模块无法找到进程内或进程外请求处理程序,则会显示“500.0 - 进程内/进程外处理程序加载失败”状态代码页 。If the ASP.NET Core Module fails to find either the in-process or out-of-process request handler, a 500.0 - In-Process/Out-Of-Process Handler Load Failure status code page appears.

对于进程内托管,如果 ASP.NET Core 模块无法启动应用,则会显示“500.30 - 启动失败”状态代码页 。For in-process hosting if the ASP.NET Core Module fails to start the app, a 500.30 - Start Failure status code page appears.

对于进程外托管,如果 ASP.NET Core 模块无法启动后端进程或后端进程启动但无法在配置的端口上侦听,则将显示“502.5 - 进程失败” 状态代码页。For out-of-process hosting if the ASP.NET Core Module fails to launch the backend process or the backend process starts but fails to listen on the configured port, a 502.5 - Process Failure status code page appears.

若要禁止显示此页面并还原为默认 IIS 5xx 状态代码页,请使用 disableStartUpErrorPage 属性。To suppress this page and revert to the default IIS 5xx status code page, use the disableStartUpErrorPage attribute. 有关配置自定义错误消息的详细信息,请参阅 HTTP 错误 <httpErrors>For more information on configuring custom error messages, see HTTP Errors <httpErrors>.

如果 ASP.NET Core 模块无法启动后端进程或后端进程启动但无法在配置的端口上侦听,则将显示“502.5 - 进程失败” 状态代码页。If the ASP.NET Core Module fails to launch the backend process or the backend process starts but fails to listen on the configured port, a 502.5 - Process Failure status code page appears. 若要禁止显示此页面并还原为默认 IIS 502 状态代码页面,请使用 disableStartUpErrorPage 属性。To suppress this page and revert to the default IIS 502 status code page, use the disableStartUpErrorPage attribute. 有关配置自定义错误消息的详细信息,请参阅 HTTP 错误 <httpErrors>For more information on configuring custom error messages, see HTTP Errors <httpErrors>.

“502.5 进程失败”状态代码页面

日志创建和重定向Log creation and redirection

如果已设置 aspNetCore 元素的 stdoutLogEnabledstdoutLogFile 属性,ASP.NET Core 模块会将 stdout 和 stderr 控制台输出重定向到磁盘。The ASP.NET Core Module redirects stdout and stderr console output to disk if the stdoutLogEnabled and stdoutLogFile attributes of the aspNetCore element are set. 创建日志文件时,模块会创建 stdoutLogFile 路径中提供的所有文件夹。Any folders in the stdoutLogFile path are created by the module when the log file is created. 应用池必须对写入日志的位置具有写入权限(使用 IIS AppPool\<app_pool_name> 提供写入权限)。The app pool must have write access to the location where the logs are written (use IIS AppPool\<app_pool_name> to provide write permission).

日志不会旋转,除非回收/重新启动进程。Logs aren't rotated, unless process recycling/restart occurs. 宿主负责限制日志占用的磁盘空间。It's the responsibility of the hoster to limit the disk space the logs consume.

仅建议使用 stdout 日志来解决应用启动问题。Using the stdout log is only recommended for troubleshooting app startup issues. 不要将 stdout 日志用于常规应用日志记录。Don't use the stdout log for general app logging purposes. 对于 ASP.NET Core 应用中的例程日志记录,使用限制日志文件大小和旋转日志的日志记录库。For routine logging in an ASP.NET Core app, use a logging library that limits log file size and rotates logs. 有关详细信息,请参阅第三方日志记录提供程序For more information, see third-party logging providers.

创建日志文件时,将自动添加时间戳和文件扩展名。A timestamp and file extension are added automatically when the log file is created. 日志文件名是通过将时间戳、进程 ID 和文件扩展名 (.log ) 附加到由下划线分隔的 stdoutLogFile 路径的最后一段(通常为 stdout )组合而成的。The log file name is composed by appending the timestamp, process ID, and file extension (.log) to the last segment of the stdoutLogFile path (typically stdout) delimited by underscores. 如果 stdoutLogFile 路径以 stdout 结尾,则 PID 为 1934 且于 2018 年 2 月 5 日 19:42:32 创建的应用的日志的文件名为 stdout_20180205194132_1934.log 。If the stdoutLogFile path ends with stdout, a log for an app with a PID of 1934 created on 2/5/2018 at 19:42:32 has the file name stdout_20180205194132_1934.log.

如果 stdoutLogEnabled 为 false,则会捕获应用启动时发生的错误,并将其发送到事件日志,最大为 30 KB。If stdoutLogEnabled is false, errors that occur on app startup are captured and emitted to the event log up to 30 KB. 启动后,将丢弃所有其他日志。After startup, all additional logs are discarded.

以下示例 aspNetCore 元素为 Azure 应用服务中托管的应用配置 stdout 日志记录。The following sample aspNetCore element configures stdout logging for an app hosted in Azure App Service. 本地日志记录可以接受本地路径或网络共享路径。A local path or network share path is acceptable for local logging. 确认应用池用户标识是否已提供写入路径的权限。Confirm that the AppPool user identity has permission to write to the path provided.

<aspNetCore processPath="dotnet"
    arguments=".\MyApp.dll"
    stdoutLogEnabled="true"
    stdoutLogFile="\\?\%home%\LogFiles\stdout"
    hostingModel="InProcess">
</aspNetCore>
<aspNetCore processPath="dotnet"
    arguments=".\MyApp.dll"
    stdoutLogEnabled="true"
    stdoutLogFile="\\?\%home%\LogFiles\stdout">
</aspNetCore>

增强的诊断日志Enhanced diagnostic logs

可以配置 ASP.NET Core 模块,以提供增强的诊断日志。The ASP.NET Core Module is configurable to provide enhanced diagnostics logs. 向 web.config 中的 <aspNetCore> 元素添加 <handlerSettings> 元素 。将 debugLevel 设置为 TRACE 将提供更准确的诊断信息:Add the <handlerSettings> element to the <aspNetCore> element in web.config. Setting the debugLevel to TRACE exposes a higher fidelity of diagnostic information:

<aspNetCore processPath="dotnet"
    arguments=".\MyApp.dll"
    stdoutLogEnabled="false"
    stdoutLogFile="\\?\%home%\LogFiles\stdout"
    hostingModel="InProcess">
  <handlerSettings>
    <handlerSetting name="debugFile" value="aspnetcore-debug.log" />
    <handlerSetting name="debugLevel" value="FILE,TRACE" />
  </handlerSettings>
</aspNetCore>

调试级别 (debugLevel) 值可以同时包含级别和位置。Debug level (debugLevel) values can include both the level and the location.

级别(详细程度由低到高):Levels (in order from least to most verbose):

  • 错误ERROR
  • 警告WARNING
  • 信息INFO
  • TRACETRACE

位置(允许多个位置):Locations (multiple locations are permitted):

  • CONSOLECONSOLE
  • 事件日志EVENTLOG
  • 文件FILE

还可以通过环境变量提供处理程序设置:The handler settings can also be provided via environment variables:

  • ASPNETCORE_MODULE_DEBUG_FILE – 调试日志文件的路径。ASPNETCORE_MODULE_DEBUG_FILE – Path to the debug log file. (默认值:aspnetcore debug.log) (Default: aspnetcore-debug.log)
  • ASPNETCORE_MODULE_DEBUG – 调试级别设置。ASPNETCORE_MODULE_DEBUG – Debug level setting.

警告

部署中启用的调试日志记录的时间不要超出排除故障所需的时间 。Do not leave debug logging enabled in the deployment for longer than required to troubleshoot an issue. 日志大小不限。The size of the log isn't limited. 持续启用调试日志可能耗尽可用磁盘空间并导致服务器或应用服务崩溃。Leaving the debug log enabled can exhaust the available disk space and crash the server or app service.

有关 web.config 文件中的 aspNetCore 元素的示例,请参阅 web.config 的配置See Configuration with web.config for an example of the aspNetCore element in the web.config file.

修改堆栈大小Modify the stack size

使用 stackSize 设置(以字节为单位)配置托管堆栈大小。Configure the managed stack size using the stackSize setting in bytes. 默认大小为 1048576 个字节 (1 MB)。The default size is 1048576 bytes (1 MB).

<aspNetCore processPath="dotnet"
    arguments=".\MyApp.dll"
    stdoutLogEnabled="false"
    stdoutLogFile="\\?\%home%\LogFiles\stdout"
    hostingModel="InProcess">
  <handlerSettings>
    <handlerSetting name="stackSize" value="2097152" />
  </handlerSettings>
</aspNetCore>

代理配置使用 HTTP 协议和配对令牌Proxy configuration uses HTTP protocol and a pairing token

仅适用于进程外托管。Only applies to out-of-process hosting.

在 ASP.NET Core 模块和 Kestrel 之间创建的代理使用 HTTP 协议。The proxy created between the ASP.NET Core Module and Kestrel uses the HTTP protocol. 使用 HTTP 是一种性能优化,其中模块和 Kestrel 之间的流量发生于脱离网络接口的环回地址。Using HTTP is a performance optimization, where the traffic between the module and Kestrel takes place on a loopback address off of the network interface. 因此,不存在从脱离服务器的位置窃取模块和 Kestrel 之间的流量的风险。There's no risk of eavesdropping the traffic between the module and Kestrel from a location off of the server.

配对令牌用于保证 Kestrel 收到的请求已由 IIS 代理且不来自某些其他源。A pairing token is used to guarantee that the requests received by Kestrel were proxied by IIS and didn't come from some other source. 模块已创建配对令牌并将其设置到环境变量 (ASPNETCORE_TOKEN)。The pairing token is created and set into an environment variable (ASPNETCORE_TOKEN) by the module. 此外,配对令牌还设置到每个代理请求的标头 (MS-ASPNETCORE-TOKEN)。The pairing token is also set into a header (MS-ASPNETCORE-TOKEN) on every proxied request. IIS 中间件检查它所接收的每个请求,以确认配对令牌标头值与环境变量值相匹配。IIS Middleware checks each request it receives to confirm that the pairing token header value matches the environment variable value. 如果令牌值不匹配,则将记录请求并拒绝该请求。If the token values are mismatched, the request is logged and rejected. 无法从脱离服务器的位置访问配对令牌环境变量及模块和 Kestrel 之间的流量。The pairing token environment variable and the traffic between the module and Kestrel aren't accessible from a location off of the server. 如果不知道配对令牌值,攻击者就无法提交绕过 IIS 中间件中的检查的请求。Without knowing the pairing token value, an attacker can't submit requests that bypass the check in the IIS Middleware.

具有 IIS 共享配置的 ASP.NET Core 模块ASP.NET Core Module with an IIS Shared Configuration

ASP.NET Core 模块安装程序使用 TrustedInstaller 帐户的权限运行 。The ASP.NET Core Module installer runs with the privileges of the TrustedInstaller account. 由于本地系统帐户没有 IIS 共享配置所用的共享路径的修改权限,因此在尝试配置共享上的 applicationHost.config 文件中的模块设置时,安装程序将引发拒绝访问错误 。Because the local system account doesn't have modify permission for the share path used by the IIS Shared Configuration, the installer throws an access denied error when attempting to configure the module settings in the applicationHost.config file on the share.

在与 IIS 安装相同的计算机上使用 IIS 共享配置时,请运行 ASP.NET Core Hosting Bundle 安装程序,并将 OPT_NO_SHARED_CONFIG_CHECK 参数设置为 1When using an IIS Shared Configuration on the same machine as the IIS installation, run the ASP.NET Core Hosting Bundle installer with the OPT_NO_SHARED_CONFIG_CHECK parameter set to 1:

dotnet-hosting-{VERSION}.exe OPT_NO_SHARED_CONFIG_CHECK=1

如果共享配置的路径与 IIS 安装的路径不在同一台计算机上,请按照下列步骤操作:When the path to the shared configuration isn't on the same machine as the IIS installation, follow these steps:

  1. 禁用 IIS 共享配置。Disable the IIS Shared Configuration.
  2. 运行安装程序。Run the installer.
  3. 将已更新的 applicationHost.config 文件导出到共享。Export the updated applicationHost.config file to the share.
  4. 重新启用 IIS 共享配置。Re-enable the IIS Shared Configuration.

使用 IIS 共享配置时,请执行以下步骤:When using an IIS Shared Configuration, follow these steps:

  1. 禁用 IIS 共享配置。Disable the IIS Shared Configuration.
  2. 运行安装程序。Run the installer.
  3. 将已更新的 applicationHost.config 文件导出到共享。Export the updated applicationHost.config file to the share.
  4. 重新启用 IIS 共享配置。Re-enable the IIS Shared Configuration.

模块版本和托管捆绑安装程序日志Module version and Hosting Bundle installer logs

若要确定已安装 ASP.NET Core 模块的版本,请执行以下操作:To determine the version of the installed ASP.NET Core Module:

  1. 在托管系统上,导航到 %windir%\System32\inetsrv 。On the hosting system, navigate to %windir%\System32\inetsrv.
  2. 找到 aspnetcore.dll 文件。Locate the aspnetcore.dll file.
  3. 右键单击该文件,然后从上下文菜单中选择“属性” 。Right-click the file and select Properties from the contextual menu.
  4. 选择“详细信息”选项卡 。“文件版本” 和“产品版本” 表示模块的已安装版本。Select the Details tab. The File version and Product version represent the installed version of the module.

在 C:\Users\%UserName%\AppData\Local\Temp 中找到了模块的托管捆绑安装程序日志。该文件名为 dd_DotNetCoreWinSvrHosting__<timestamp>000_AspNetCoreModule_x64.log 。The Hosting Bundle installer logs for the module are found at C:\Users\%UserName%\AppData\Local\Temp. The file is named *dd_DotNetCoreWinSvrHosting_<timestamp>_000_AspNetCoreModule_x64.log*.

模块、架构和配置文件位置Module, schema, and configuration file locations

模块Module

IIS (x86/amd64)IIS (x86/amd64):

  • %windir%\System32\inetsrv\aspnetcore.dll%windir%\System32\inetsrv\aspnetcore.dll

  • %windir%\SysWOW64\inetsrv\aspnetcore.dll%windir%\SysWOW64\inetsrv\aspnetcore.dll

  • %ProgramFiles%\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll%ProgramFiles%\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll

  • %ProgramFiles(x86)%\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll%ProgramFiles(x86)%\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll

IIS Express (x86/amd64)IIS Express (x86/amd64):

  • %ProgramFiles%\IIS Express\aspnetcore.dll%ProgramFiles%\IIS Express\aspnetcore.dll

  • %ProgramFiles(x86)%\IIS Express\aspnetcore.dll%ProgramFiles(x86)%\IIS Express\aspnetcore.dll

  • %ProgramFiles%\IIS Express\Asp.Net Core Module\V2\aspnetcorev2.dll%ProgramFiles%\IIS Express\Asp.Net Core Module\V2\aspnetcorev2.dll

  • %ProgramFiles(x86)%\IIS Express\Asp.Net Core Module\V2\aspnetcorev2.dll%ProgramFiles(x86)%\IIS Express\Asp.Net Core Module\V2\aspnetcorev2.dll

架构Schema

IISIIS

  • %windir%\System32\inetsrv\config\schema\aspnetcore_schema.xml%windir%\System32\inetsrv\config\schema\aspnetcore_schema.xml
  • %windir%\System32\inetsrv\config\schema\aspnetcore_schema_v2.xml%windir%\System32\inetsrv\config\schema\aspnetcore_schema_v2.xml

IIS ExpressIIS Express

  • %ProgramFiles%\IIS Express\config\schema\aspnetcore_schema.xml%ProgramFiles%\IIS Express\config\schema\aspnetcore_schema.xml
  • %ProgramFiles%\IIS Express\config\schema\aspnetcore_schema_v2.xml%ProgramFiles%\IIS Express\config\schema\aspnetcore_schema_v2.xml

ConfigurationConfiguration

IISIIS

  • %windir%\System32\inetsrv\config\applicationHost.config%windir%\System32\inetsrv\config\applicationHost.config

IIS ExpressIIS Express

  • Visual Studio:{APPLICATION ROOT}\.vs\config\applicationHost.configVisual Studio: {APPLICATION ROOT}\.vs\config\applicationHost.config

  • iisexpress.exe CLI:%USERPROFILE%\Documents\IISExpress\config\applicationhost.configiisexpress.exe CLI: %USERPROFILE%\Documents\IISExpress\config\applicationhost.config

可以通过在 applicationHost.config 文件中搜索 aspnetcore 找到这些文件。The files can be found by searching for aspnetcore in the applicationHost.config file.

其他资源Additional resources