本文转自: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 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 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
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.
<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.
<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:
- Disable the IIS Shared Configuration.
- Run the installer.
- Export the updated applicationHost.config file to the share.
- Re-enable the IIS Shared Configuration.
Module version and Hosting Bundle installer logs
To determine the version of the installed ASP.NET Core Module:
- On the hosting system, navigate to %windir%\System32\inetsrv.
- Locate the aspnetcore.dll file.
- Right-click the file and select Properties from the contextual menu.
- 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):
IIS Express (x86/amd64):
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 解决方案。
|
请发表评论