• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

[转]ASP.NET核心模块配置参考

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文转自:https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-2.1

Sourabh Shirhatti

ASP.NET Core Module overview.

Configuration with web.config

The ASP.NET Core Module is configured with the aspNetCore section of the system.webServer node in the site's web.config file.

framework-dependent deployment and configures the ASP.NET Core Module to handle site requests:

XML
<?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>

self-contained deployment:

XML
<?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>

The path saves stdout logs to the LogFiles folder, which is a location automatically created by the service.

Sub-application configuration for an important note pertaining to the configuration of web.config files in sub-apps.

Attributes of the aspNetCore element

Attribute Description Default
arguments

Optional string attribute.

Arguments to the executable specified in processPath.

 
disableStartUpErrorPage true or false.

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 true or false.

It's the responsibility of that process to call CloseHandle on this token per request.

true
processPath

Required string attribute.

If the path begins with ., the path is considered to be relative to the site root.

 
rapidFailsPerMinute

Optional integer attribute.

If this limit is exceeded, the module stops launching the process for the remainder of the minute.

10
requestTimeout

Optional timespan attribute.

Specifies the duration for which the ASP.NET Core Module waits for a response from the process listening on %ASPNETCORE_PORT%.

In versions of the ASP.NET Core Module that shipped with the release of ASP.NET Core 2.0 or earlier, the requestTimeout must be specified in whole minutes only, otherwise it defaults to 2 minutes.

00:02:00
shutdownTimeLimit

Optional integer attribute.

Duration in seconds that the module waits for the executable to gracefully shutdown when the app_offline.htm file is detected.

10
startupTimeLimit

Optional integer attribute.

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.

120
stdoutLogEnabled

Optional Boolean attribute.

If true, stdout and stderr for the process specified in processPath are redirected to the file specified in stdoutLogFile.

false
stdoutLogFile

Optional string attribute.

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.

Arguments to the executable specified in processPath.

 
disableStartUpErrorPage true or false.

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 true or false.

It's the responsibility of that process to call CloseHandle on this token per request.

true
processPath

Required string attribute.

If the path begins with ., the path is considered to be relative to the site root.

 
rapidFailsPerMinute

Optional integer attribute.

If this limit is exceeded, the module stops launching the process for the remainder of the minute.

10
requestTimeout

Optional timespan attribute.

Specifies the duration for which the ASP.NET Core Module waits for a response from the process listening on %ASPNETCORE_PORT%.

In 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:00
shutdownTimeLimit

Optional integer attribute.

Duration in seconds that the module waits for the executable to gracefully shutdown when the app_offline.htm file is detected.

10
startupTimeLimit

Optional integer attribute.

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.

120
stdoutLogEnabled

Optional Boolean attribute.

If true, stdout and stderr for the process specified in processPath are redirected to the file specified in stdoutLogFile.

false
stdoutLogFile

Optional string attribute.

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

Environment variables set in this section take precedence over system environment variables.

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.

XML
<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>

警告

Only set the ASPNETCORE_ENVIRONMENT envirnonment variable to Development on staging and testing servers that aren't accessible to untrusted networks, such as the Internet.

app_offline.htm

If the app is still running after the number of seconds defined in shutdownTimeLimit, the ASP.NET Core Module kills the running process.

When the app_offline.htm file is removed, the next request starts the app.

Start-up error page

HTTP Errors <httpErrors>.

Log creation and redirection

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).

It's the responsibility of the hoster to limit the disk space the logs consume.

third-party logging providers.

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.

Confirm that the AppPool user identity has permission to write to the path provided.

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

Configuration with web.config for an example of the aspNetCore element in the web.config file.

Proxy configuration uses HTTP protocol and a pairing token

There's no risk of eavesdropping the traffic between the module and Kestrel from a location off of the server.

Without knowing the pairing token value, an attacker can't submit requests that bypass the check in the IIS Middleware.

ASP.NET Core Module with an IIS Shared Configuration

When using an IIS Shared Configuration, follow these steps:

  1. Disable the IIS Shared Configuration.
  2. Run the installer.
  3. Export the updated applicationHost.config file to the share.
  4. Re-enable the IIS Shared Configuration.

Module version and Hosting Bundle installer logs

To determine the version of the installed ASP.NET Core Module:

  1. On the hosting system, navigate to %windir%\System32\inetsrv.
  2. 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.

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):

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

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

IIS Express (x86/amd64):

  • %ProgramFiles%\IIS Express\aspnetcore.dll

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

Schema

IIS

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

IIS Express

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

Configuration

IIS

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

IIS Express

  • .vs\config\applicationHost.config

在创建文件 <application_root >\.vs\配置时从任何 web 应用程序项目开始在 Visual Studio 解决方案。

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
【ASP.NETstepbystep】之一CreateaDAL发布时间:2022-07-10
下一篇:
ASP.NET5探险(6):升级ASP.NET5到beta6发布时间:2022-07-10
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap