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 Deploy 或以手動方式將 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.exeC:\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. 此行為基本上與在 IIS 中執行同處理序,並由 Windows 處理器啟用服務 (WAS) 所管理的 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). 此模組會在應用程式的隨機通訊埠上將要求轉送至 Kestrel,而且不會是通訊埠 80 或 443。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 Integration 新增的中介軟體會更新配置、遠端 IP 和帳戶路徑基底,以將要求轉送至 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 模組,請參閱與 ASP.NET Core 搭配運作的 IIS 模組To learn more about IIS modules active with the ASP.NET Core Module, see 與 ASP.NET Core 搭配運作的 IIS 模組.

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

設定 ASP.NET Core 模組時,是使用網站 web.config 檔案中 system.webServer 節點的 aspNetCore 區段來設定。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 App Service 時,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

選擇性的 Boolean 屬性。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

選擇性的 Boolean 屬性。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.

不建議使用 processesPerApplication 設定。Setting 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

選擇性的時間範圍屬性。Optional timespan attribute.

針對在 %ASPNETCORE_PORT% 進行接聽的處理序,指定 ASP.NET Core 模組等候回應的持續時間。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

選擇性的 Boolean 屬性。Optional Boolean attribute.

如果為 true,就會將 processPath 中所指定處理序的 stdoutstderr 重新導向到 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 中所指定處理序之 stdoutstderr 的相對或絕對檔案路徑。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. 使用底線分隔符號,時間戳記、處理序識別碼及副檔名 ( .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 作為值,在 2018 年 2 月 5 日的 19:41:32 以處理序識別碼 1934 進行儲存時,範例 stdout 記錄檔就會以 stdout_20180205194132_1934.log 的形式儲存在 [logs] 資料夾中。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

選擇性的 Boolean 屬性。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

選擇性的 Boolean 屬性。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.

不建議使用 processesPerApplication 設定。Setting 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

選擇性的時間範圍屬性。Optional timespan attribute.

針對在 %ASPNETCORE_PORT% 進行接聽的處理序,指定 ASP.NET Core 模組等候回應的持續時間。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

選擇性的 Boolean 屬性。Optional Boolean attribute.

如果為 true,就會將 processPath 中所指定處理序的 stdoutstderr 重新導向到 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 中所指定處理序之 stdoutstderr 的相對或絕對檔案路徑。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. 使用底線分隔符號,時間戳記、處理序識別碼及副檔名 ( .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 作為值,在 2018 年 2 月 5 日的 19:41:32 以處理序識別碼 1934 進行儲存時,範例 stdout 記錄檔就會以 stdout_20180205194132_1934.log 的形式儲存在 [logs] 資料夾中。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 中直接設定環境的替代方式是在發行設定檔 ( .pubxml) 或專案檔中包括 <EnvironmentName> 屬性。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>

警告

請只有在未受信任網路 (例如網際網路) 無法存取的暫存和測試伺服器上,才將 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 Module 會嘗試正常關閉應用程式並停止處理連入的要求。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 Module 就會終止執行中的處理序。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. 記錄檔名稱會藉由將時間戳記、處理序識別碼及副檔名 ( .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,則在 2018 年 2 月 5 日 19:42:32 建立且 PID 為 1934 的應用程式記錄檔檔案名稱會是 stdout_20180205194132_1934.logIf 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,會擷取在應用程式啟動時發生的錯誤,並發出最大 30KB 的事件記錄檔。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 App Service 中所裝載應用程式的 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. 請確認 AppPool 使用者身分識別具備所提供路徑的寫入權限。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. <handlerSettings> 項目新增至 web.config 中的 <aspNetCore> 項目。將 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):

  • ERRORERROR
  • WARNINGWARNING
  • INFOINFO
  • TRACETRACE

位置 (允許多個位置):Locations (multiple locations are permitted):

  • 主控台CONSOLE
  • EVENTLOGEVENTLOG
  • 檔案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>

Proxy 組態使用 HTTP 通訊協定和配對權杖Proxy configuration uses HTTP protocol and a pairing token

僅適用於跨處理序裝載。 Only applies to out-of-process hosting.

在 ASP.NET Core 模組與 Kestrel 之間建立的 Proxy 會使用 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 裝載套件組合安裝程式並將 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\inetsrvOn 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.logThe 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

ModuleModule

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