在使用 IIS 的 Windows 上裝載 ASP.NET CoreHost ASP.NET Core on Windows with IIS

作者:Luke LathamBy Luke Latham

如需將 ASP.NET Core 應用程式發佈至 IIS 伺服器的教學課程體驗,請參閱將 ASP.NET Core 應用程式發佈到 IISFor a tutorial experience on publishing an ASP.NET Core app to an IIS server, see 將 ASP.NET Core 應用程式發佈到 IIS.

安裝 .NET Core 裝載套件組合Install the .NET Core Hosting Bundle

支援的作業系統Supported operating systems

支援下列作業系統:The following operating systems are supported:

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

HTTP.sys 伺服器 (先前稱為 WebListener) 不適用搭配 IIS 的反向 Proxy 設定。HTTP.sys server (formerly called WebListener) doesn't work in a reverse proxy configuration with IIS. 請使用 Kestrel 伺服器Use the Kestrel server.

如需在 Azure 中裝載的資訊,請參閱 將 ASP.NET Core 應用程式部署至 Azure App ServiceFor information on hosting in Azure, see 將 ASP.NET Core 應用程式部署至 Azure App Service.

如需疑難排解指引,請參閱 疑難排解 ASP.NET Core 專案For troubleshooting guidance, see 疑難排解 ASP.NET Core 專案.

支援的平台Supported platforms

支援針對 32 位元 (x86) 或 64 位元 (x64) 部署發行的應用程式。Apps published for 32-bit (x86) or 64-bit (x64) deployment are supported. 使用 32 位元 (x86) .NET Core SDK 部署 32 位元應用程式,除非應用程式:Deploy a 32-bit app with a 32-bit (x86) .NET Core SDK unless the app:

  • 需要提供給 64 位元應用程式使用的較大虛擬記憶體位址空間。Requires the larger virtual memory address space available to a 64-bit app.
  • 需要較大的 IIS 堆疊大小。Requires the larger IIS stack size.
  • 有 64 位元原生相依性。Has 64-bit native dependencies.

使用 64 位元 (x64) .NET Core SDK 來發行 64 位元應用程式。Use a 64-bit (x64) .NET Core SDK to publish a 64-bit app. 主機系統上必須有 64 位元執行階段存在。A 64-bit runtime must be present on the host system.

裝載模型Hosting models

同處理序裝載模型In-process hosting model

使用同處理序裝載,ASP.NET Core 應用程式會在與其 IIS 工作者處理序相同的處理序中執行。Using in-process hosting, an ASP.NET Core app runs in the same process as its IIS worker process. 因為要求未透過回送介面卡 (將連出網路流量傳回同一部電腦的網路介面) 進行 proxy 處理,所以同處理序裝載會提供優於跨處理序裝載的效能。In-process hosting provides improved performance over out-of-process hosting because requests aren't proxied over the loopback adapter, a network interface that returns outgoing network traffic back to the same machine. IIS 透過 Windows 處理序啟用服務 (WAS) 來執行處理程序管理。IIS handles process management with the Windows Process Activation Service (WAS).

ASP.NET Core 模組The ASP.NET Core Module:

  • 執行應用程式初始化。Performs app initialization.
    • 載入 CoreCLRLoads the CoreCLR.
    • 呼叫 Program.MainCalls Program.Main.
  • 處理 IIS 原生要求的存留期。Handles the lifetime of the IIS native request.

以 .NET Framework 為目標的 ASP.NET Core 應用程式不支援處理序內裝載模型。The in-process hosting model isn't supported for ASP.NET Core apps that target the .NET Framework.

下圖說明 IIS、ASP.NET Core 模組和同處理序裝載應用程式之間的關聯性:The following diagram illustrates the relationship between IIS, the ASP.NET Core Module, and an app hosted in-process:

同處理序代管內的 ASP.NET Core 模組案例

要求會從 Web 到達核心模式的 HTTP.sys 驅動程式。A request arrives from the web to the kernel-mode HTTP.sys driver. 驅動程式會在網站設定的連接埠上將原生要求路由至 IIS,此連接埠通常是 80 (HTTP) 或 443 (HTTPS)。The driver routes the native request to IIS on the website's configured port, usually 80 (HTTP) or 443 (HTTPS). 模組會接收原生要求,並將它傳遞至 IIS HTTP 伺服器 (IISHttpServer)。The module receives the native request and passes it to IIS HTTP Server (IISHttpServer). IIS HTTP 伺服器是 IIS 的同處理序伺服程式實作,可將要求從原生轉換為受控。IIS HTTP Server is an in-process server implementation for IIS that converts the request from native to managed.

IIS HTTP 伺服器處理要求之後,要求會被推送至 ASP.NET Core 中介軟體管線。After the IIS HTTP Server processes the request, 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 HTTP 伺服器傳回 IIS。The app's response is passed back to IIS through IIS HTTP Server. IIS 會將回應傳送到起始該要求的用戶端。IIS sends the response to the client that initiated the request.

現有的應用程式可以選擇同處理序裝載,但 dotnet new 範本預設會對所有 IIS 和 IIS Express 案例使用同處理序裝載模型。In-process hosting is opt-in for existing apps, but dotnet new templates default to the in-process hosting model for all IIS and IIS Express scenarios.

CreateDefaultBuilder 會透過呼叫 UseIIS 方法來啟動 CoreCLR 以新增 IServer,並在 IIS 工作者處理序 (w3wp.exeiisexpress.exe) 內裝載應用程式。CreateDefaultBuilder adds an IServer instance by calling the UseIIS method to boot the CoreCLR and host the app inside of the IIS worker process (w3wp.exe or iisexpress.exe). 效能測試指出,相較於跨處理序裝載 .NET Core 應用程式,並將要求 Proxy 處理至 Kestrel 伺服器,裝載於同處理序可提供明顯更高的要求輸送量。Performance tests indicate that hosting a .NET Core app in-process delivers significantly higher request throughput compared to hosting the app out-of-process and proxying requests to Kestrel server.

注意

發佈為單一檔案可執行檔的應用程式無法由同處理序裝載模型載入。Apps published as a single file executable can't be loaded by the in-process hosting model.

跨處理序裝載模型Out-of-process hosting model

因為 ASP.NET Core 應用程式執行所在的處理序會與 IIS 工作者處理序分開,所以此模組會執行處理程序管理。Because ASP.NET Core apps run in a process separate from the IIS worker process, the module 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 shuts down or crashes. 此行為基本上與執行同處理序,並由 Windows 處理序啟用服務 (WAS) 所管理的應用程式相同。This is essentially the same behavior as seen with apps that run in-process 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 hosted out-of-process:

非同處理序代管內的 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.

此模組在啟動時透過環境變數指定連接埠,而 UseIISIntegration 延伸模組則會設定伺服器來接聽 http://localhost:{PORT}The module specifies the port via an environment variable at startup, and the UseIISIntegration extension 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.

ASP.NET Core 隨附 Kestrel 伺服器,其為預設的跨平台 HTTP 伺服器。ASP.NET Core ships with Kestrel server, a default, cross-platform HTTP server.

在使用 IISIIS Express 時,應用程式會執行於從 IIS 背景工作處理序中分離出的處理序 (跨處理序 ),並搭配 Kestrel 伺服器When using IIS or IIS Express, the app runs in a process separate from the IIS worker process (out-of-process) with the Kestrel server.

因為 ASP.NET Core 應用程式執行所在的處理序會與 IIS 工作者處理序分開,所以此模組會執行處理程序管理。Because ASP.NET Core apps run in a process separate from the IIS worker process, the module 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 shuts down or crashes. 此行為基本上與執行同處理序,並由 Windows 處理序啟用服務 (WAS) 所管理的應用程式相同。This is essentially the same behavior as seen with apps that run in-process 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 hosted out-of-process:

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.

CreateDefaultBuilder 會將 Kestrel 伺服器設為網頁伺服器,並設定 ASP.NET Core 模組的基底路徑與連接埠來啟用 IIS 整合。CreateDefaultBuilder configures Kestrel server as the web server and enables IIS Integration by configuring the base path and port for the ASP.NET Core Module.

ASP.NET Core 模組會產生要指派給後端處理序的動態連接埠。The ASP.NET Core Module generates a dynamic port to assign to the backend process. CreateDefaultBuilder 會呼叫 UseIISIntegration 方法。CreateDefaultBuilder calls the UseIISIntegration method. UseIISIntegration 會將 Kestrel 設定為在位於 localhost IP 位址 (127.0.0.1) 的動態連接埠上接聽。UseIISIntegration configures Kestrel to listen on the dynamic port at the localhost IP address (127.0.0.1). 若動態連接埠是 1234,Kestrel 會在 127.0.0.1:1234 接聽。If the dynamic port is 1234, Kestrel listens at 127.0.0.1:1234. 此設定會取代由下列項目提供的其他 URL 設定:This configuration replaces other URL configurations provided by:

在使用模組時不需要呼叫 UseUrls 或 Kestrel 的 Listen API。Calls to UseUrls or Kestrel's Listen API aren't required when using the module. 若呼叫 UseUrlsListen,Kestrel 只會接聽未使用 IIS 執行應用程式時指定的連接埠。If UseUrls or Listen is called, Kestrel listens on the port specified only when running the app without IIS.

如需處理序內和處理序外裝載模型的詳細資訊,請參閱 ASP.NET Core 模組ASP.NET Core 模組設定參考For more information on the in-process and out-of-process hosting models, see ASP.NET Core Module and ASP.NET Core Module configuration reference.

如需 ASP.NET Core 模組組態指南,請參閱 ASP.NET Core 模組For ASP.NET Core Module configuration guidance, see ASP.NET Core 模組.

如需代管的詳細資訊,請參閱在 ASP.NET Core 中代管For more information on hosting, see Host in ASP.NET Core.

應用程式組態Application configuration

啟用 IISIntegration 元件Enable the IISIntegration components

一般的 Program.cs 會呼叫 CreateDefaultBuilder,開始設定會啟用與 IIS 整合的主機:A typical Program.cs calls CreateDefaultBuilder to begin setting up a host that enables integration with IIS:

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        ...

IIS 選項IIS options

同處理序主控模型In-process hosting model

若要設定 IIS 伺服器選項,請在 ConfigureServices 中加入 IISServerOptions 的服務設定。To configure IIS Server options, include a service configuration for IISServerOptions in ConfigureServices. 下列範例會停用 AutomaticAuthentication:The following example disables AutomaticAuthentication:

services.Configure<IISServerOptions>(options => 
{
    options.AutomaticAuthentication = false;
});
選項Option 預設Default 設定Setting
AutomaticAuthentication true 若為 true,IIS 伺服器會設定由 Windows 驗證所驗證的 HttpContext.UserIf true, IIS Server sets the HttpContext.User authenticated by Windows Authentication. 若為 false,則伺服器僅會對 HttpContext.User 提供身分識別,並在 AuthenticationScheme 明確要求時回應挑戰。If false, the server only provides an identity for HttpContext.User and responds to challenges when explicitly requested by the AuthenticationScheme. 必須在 IIS 中啟用 Windows 驗證以讓 AutomaticAuthentication 作用。Windows Authentication must be enabled in IIS for AutomaticAuthentication to function. 如需詳細資訊,請參閱 Windows 驗證For more information, see Windows Authentication.
AuthenticationDisplayName null 設定使用者在登入頁面上看到的顯示名稱。Sets the display name shown to users on login pages.
AllowSynchronousIO false 是否要針對 HttpContext.RequestHttpContext.Response 允許同步 IO。Whether synchronous IO is allowed for the HttpContext.Request and the HttpContext.Response.
MaxRequestBodySize 30000000 取得或設定 HttpRequest 的要求本文大小上限。Gets or sets the max request body size for the HttpRequest. 請注意,IIS 本身具有限制 maxAllowedContentLength,此限制將在 IISServerOptions 中設定 MaxRequestBodySize 時處理。Note that IIS itself has the limit maxAllowedContentLength which will be processed before the MaxRequestBodySize set in the IISServerOptions. 變更 MaxRequestBodySize 將不會影響 maxAllowedContentLengthChanging the MaxRequestBodySize won't affect the maxAllowedContentLength. 若要增加 maxAllowedContentLength,請在 web.config 中新增項目,以將 maxAllowedContentLength 設定為較高的值。To increase maxAllowedContentLength, add an entry in the web.config to set maxAllowedContentLength to a higher value. 如需更多詳細資料,請參閱組態For more details, see Configuration.

跨處理序裝載模型Out-of-process hosting model

選項Option 預設Default 設定Setting
AutomaticAuthentication true 若為 true,IIS 伺服器會設定由 Windows 驗證所驗證的 HttpContext.UserIf true, IIS Server sets the HttpContext.User authenticated by Windows Authentication. 若為 false,則伺服器僅會對 HttpContext.User 提供身分識別,並在 AuthenticationScheme 明確要求時回應挑戰。If false, the server only provides an identity for HttpContext.User and responds to challenges when explicitly requested by the AuthenticationScheme. 必須在 IIS 中啟用 Windows 驗證以讓 AutomaticAuthentication 作用。Windows Authentication must be enabled in IIS for AutomaticAuthentication to function. 如需詳細資訊,請參閱 Windows 驗證For more information, see Windows Authentication.
AuthenticationDisplayName null 設定使用者在登入頁面上看到的顯示名稱。Sets the display name shown to users on login pages.

跨處理序裝載模型Out-of-process hosting model

若要設定 IIS 選項,請在 ConfigureServices 中加入 IISOptions 的服務設定。To configure IIS options, include a service configuration for IISOptions in ConfigureServices. 下列範例會防止應用程式填入 HttpContext.Connection.ClientCertificateThe following example prevents the app from populating HttpContext.Connection.ClientCertificate:

services.Configure<IISOptions>(options => 
{
    options.ForwardClientCertificate = false;
});
選項Option 預設Default 設定Setting
AutomaticAuthentication true 若為 trueIIS 整合中介軟體會設定由 Windows 驗證所驗證的 HttpContext.UserIf true, IIS Integration Middleware sets the HttpContext.User authenticated by Windows Authentication. 如果為 false,則驗證中介軟體僅針對 HttpContext.User 提供身分識別,並在游 AuthenticationScheme 提出明確要求時回應挑戰。If false, the middleware only provides an identity for HttpContext.User and responds to challenges when explicitly requested by the AuthenticationScheme. 必須在 IIS 中啟用 Windows 驗證以讓 AutomaticAuthentication 作用。Windows Authentication must be enabled in IIS for AutomaticAuthentication to function. 如需詳細資訊,請參閱 Windows 驗證主題。For more information, see the Windows Authentication topic.
AuthenticationDisplayName null 設定使用者在登入頁面上看到的顯示名稱。Sets the display name shown to users on login pages.
ForwardClientCertificate true 如果為 trueMS-ASPNETCORE-CLIENTCERT 要求標頭已存在,則會填入 HttpContext.Connection.ClientCertificateIf true and the MS-ASPNETCORE-CLIENTCERT request header is present, the HttpContext.Connection.ClientCertificate is populated.

Proxy 伺服器和負載平衡器案例Proxy server and load balancer scenarios

用來設定轉送標頭中介軟體及 ASP.NET Core 模組的 IIS 整合中介軟體會設定為轉送配置 (HTTP/HTTPS) 與發出要求的遠端 IP 位址。The IIS Integration Middleware, which configures Forwarded Headers Middleware, and the ASP.NET Core Module are configured to forward the scheme (HTTP/HTTPS) and the remote IP address where the request originated. 其他 Proxy 伺服器和負載平衡器後方託管的應用程式可能需要其他設定。Additional configuration might be required for apps hosted behind additional proxy servers and load balancers. 如需詳細資訊,請參閱設定 ASP.NET Core 以處理 Proxy 伺服器和負載平衡器For more information, see Configure ASP.NET Core to work with proxy servers and load balancers.

web.config 檔案web.config file

web.config 檔案是用來設定 ASP.NET Core 模組The web.config file configures the ASP.NET Core Module. 發佈專案時,由 MSBuild 目標 (_TransformWebConfig) 處理 web.config 檔案的建立、轉換及發佈。Creating, transforming, and publishing the web.config file is handled by an MSBuild target (_TransformWebConfig) when the project is published. 此目標存在於 Web SDK 目標 (Microsoft.NET.Sdk.Web)。This target is present in the Web SDK targets (Microsoft.NET.Sdk.Web). SDK 設定在專案檔的頂端:The SDK is set at the top of the project file:

<Project Sdk="Microsoft.NET.Sdk.Web">

如果專案中沒有 web.config 檔案,則系統會使用正確的 processPatharguments 建立該檔案以設定 ASP.NET Core 模組,並將該檔案移至已發行的輸出If a web.config file isn't present in the project, the file is created with the correct processPath and arguments to configure the ASP.NET Core Module and moved to published output.

如果 web.config 檔案存在於專案中,則系統會使用正確的 processPatharguments 來轉換該檔案以設定 ASP.NET Core 模組,然後將它移至已發行的輸出。If a web.config file is present in the project, the file is transformed with the correct processPath and arguments to configure the ASP.NET Core Module and moved to published output. 轉換不會修改檔案中的 IIS 組態設定。The transformation doesn't modify IIS configuration settings in the file.

web.config 檔案可提供能控制作用中 IIS 模組的額外 IIS 組態設定。The web.config file may provide additional IIS configuration settings that control active IIS modules. 如需能處理 ASP.NET Core 應用程式要求之 IIS 模組的相關資訊,請參閱 IIS 模組主題。For information on IIS modules that are capable of processing requests with ASP.NET Core apps, see the IIS modules topic.

為防止 Web SDK 轉換 web.config 檔案,請使用專案檔中的 <IsTransformWebConfigDisabled> 屬性:To prevent the Web SDK from transforming the web.config file, use the <IsTransformWebConfigDisabled> property in the project file:

<PropertyGroup>
  <IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>

使 Web SDK 無法轉換檔案時,應該由開發人員手動設定 processPathargumentsWhen disabling the Web SDK from transforming the file, the processPath and arguments should be manually set by the developer. 如需詳細資訊,請參閱 ASP.NET Core 模組組態參考For more information, see the ASP.NET Core Module configuration reference.

web.config 檔案位置web.config file location

為了正確設定 ASP.NET Core 模組web.config 檔案必須存在於已部署應用程式的內容根路徑 (通常是應用程式基底路徑)。In order to set up the ASP.NET Core Module correctly, the web.config file must be present at the content root path (typically the app base path) of the deployed app. 這是與提供給 IIS 的網站實體路徑相同的位置。This is the same location as the website physical path provided to IIS. 應用程式的根目錄需有 web.config 檔案,才能使用 Web Deploy 發行多個應用程式。The web.config file is required at the root of the app to enable the publishing of multiple apps using Web Deploy.

機密檔案存在於應用程式的實體路徑上,例如 <組件>.runtimeconfig.json<組件>.xml (XML 文件註解),以及 <組件>.deps.jsonSensitive files exist on the app's physical path, such as <assembly>.runtimeconfig.json, <assembly>.xml (XML Documentation comments), and <assembly>.deps.json. web.config 檔案存在且網站正常啟動時,如果有人要求機密檔案,IIS 不會予以提供。When the web.config file is present and the site starts normally, IIS doesn't serve these sensitive files if they're requested. web.config 檔案遺失或沒有正確命名,或是無法設定網站以正常啟動,IIS 可能會公開提供機密檔案。If the web.config file is missing, incorrectly named, or unable to configure the site for normal startup, IIS may serve sensitive files publicly.

web.config 檔案必須持續存在於部署之中、已正確命名,並能夠設定網站以正常啟動。無論在任何情況下,請都不要從生產環境部署移除 web.config 檔案。The web.config file must be present in the deployment at all times, correctly named, and able to configure the site for normal start up. Never remove the web.config file from a production deployment.

轉換 web.configTransform web.config

如需在發佈時轉換 web.config (例如依據設定、設定檔或環境設定環境變數),請參閱轉換 web.configIf you need to transform web.config on publish (for example, set environment variables based on the configuration, profile, or environment), see 轉換 web.config.

IIS 組態IIS configuration

Windows Server 作業系統Windows Server operating systems

啟用網頁伺服器 (IIS) 伺服器角色,並建立角色服務。Enable the Web Server (IIS) server role and establish role services.

  1. 使用來自 [管理] 功能表的 [新增角色及功能] 精靈,或是 [伺服器管理員] 中的連結。Use the Add Roles and Features wizard from the Manage menu or the link in Server Manager. 伺服器角色步驟中,核取 [網頁伺服器 (IIS)] 方塊。On the Server Roles step, check the box for Web Server (IIS).

    在選取伺服器角色步驟中選取網頁伺服器 IIS 角色。

  2. 在 [功能] 步驟之後,[角色服務] 步驟會針對網頁伺服器 (IIS) 進行載入。After the Features step, the Role services step loads for Web Server (IIS). 選取所需的 IIS 角色服務或接受所提供的預設角色服務。Select the IIS role services desired or accept the default role services provided.

    在選取角色服務步驟中,選取預設的角色服務。

    Windows 驗證 (選擇性)Windows Authentication (Optional)
    若要啟用 Windows 驗證,請展開下列節點:[網頁伺服器] > [安全性] 。To enable Windows Authentication, expand the following nodes: Web Server > Security. 選取 [Windows 驗證] 功能。Select the Windows Authentication feature. 如需詳細資訊,請參閱 Windows 驗證 <windowsAuthentication>設定 Windows 驗證For more information, see Windows Authentication <windowsAuthentication> and Configure Windows authentication.

    WebSocket (選擇性)WebSockets (Optional)
    WebSocket 由 ASP.NET Core 1.1 或更新版本所支援。WebSockets is supported with ASP.NET Core 1.1 or later. 若要啟用 WebSockets,請展開下列節點:[網頁伺服器] > [應用程式開發] 。To enable WebSockets, expand the following nodes: Web Server > Application Development. 選取 [WebSocket 通訊協定] 功能。Select the WebSocket Protocol feature. 如需詳細資訊,請參閱 WebSocketsFor more information, see WebSockets.

  3. 透過確認步驟繼續作業,安裝網頁伺服器角色和服務。Proceed through the Confirmation step to install the web server role and services. 安裝網頁伺服器 (IIS) 角色之後,不需要重新啟動伺服器/IIS。A server/IIS restart isn't required after installing the Web Server (IIS) role.

Windows 桌面作業系統Windows desktop operating systems

啟用 [IIS 管理主控台] 和 [World Wide Web 服務] 。Enable the IIS Management Console and World Wide Web Services.

  1. 瀏覽至控制台 > [程式] > [程式和功能] > [開啟或關閉 Windows 功能] (畫面左側)。Navigate to Control Panel > Programs > Programs and Features > Turn Windows features on or off (left side of the screen).

  2. 開啟 [Internet Information Services] 節點。Open the Internet Information Services node. 開啟 [Web 管理工具] 節點。Open the Web Management Tools node.

  3. 核取 [IIS 管理主控台] 方塊。Check the box for IIS Management Console.

  4. [World Wide Web Services] (全球資訊網服務) 核取方塊。Check the box for World Wide Web Services.

  5. 接受全球資訊網服務的預設功能,或自訂 IIS 功能。Accept the default features for World Wide Web Services or customize the IIS features.

    Windows 驗證 (選擇性)Windows Authentication (Optional)
    若要啟用 Windows 驗證,請展開下列節點:[World Wide Web 服務] > [安全性] 。To enable Windows Authentication, expand the following nodes: World Wide Web Services > Security. 選取 [Windows 驗證] 功能。Select the Windows Authentication feature. 如需詳細資訊,請參閱 Windows 驗證 <windowsAuthentication>設定 Windows 驗證For more information, see Windows Authentication <windowsAuthentication> and Configure Windows authentication.

    WebSocket (選擇性)WebSockets (Optional)
    WebSocket 由 ASP.NET Core 1.1 或更新版本所支援。WebSockets is supported with ASP.NET Core 1.1 or later. 若要啟用 WebSockets,請展開下列節點:[World Wide Web 服務] > [應用程式開發功能] 。To enable WebSockets, expand the following nodes: World Wide Web Services > Application Development Features. 選取 [WebSocket 通訊協定] 功能。Select the WebSocket Protocol feature. 如需詳細資訊,請參閱 WebSocketsFor more information, see WebSockets.

  6. 若 IIS 安裝需要重新啟動,請重新啟動系統。If the IIS installation requires a restart, restart the system.

選取 [Windows 功能] 中的 [IIS 管理主控台] 和 [World Wide Web Services] (全球資訊網服務)。

安裝 .NET Core 裝載套件組合Install the .NET Core Hosting Bundle

在主控系統上安裝 .NET Core 裝載套件組合 。Install the .NET Core Hosting Bundle on the hosting system. 套件組合會安裝 .NET Core 執行階段、.NET Core 程式庫和 ASP.NET Core 模組The bundle installs the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. 此模組可讓 ASP.NET Core 應用程式在 IIS 背後執行。The module allows ASP.NET Core apps to run behind IIS. 如果系統沒有網際網路連線,請先取得並安裝 Microsoft Visual C++ 2015 可轉散發套件,再安裝 .NET Core 裝載套件組合。If the system doesn't have an Internet connection, obtain and install the Microsoft Visual C++ 2015 Redistributable before installing the .NET Core Hosting Bundle.

重要

若裝載套件組合在 IIS 之前安裝,則必須對該套件組合安裝進行修復。If the Hosting Bundle is installed before IIS, the bundle installation must be repaired. 請在安裝 IIS 之後,再次執行裝載套件組合安裝程式。Run the Hosting Bundle installer again after installing IIS.

如果在安裝 64 位元 (x64) 版本的 .NET Core 後才安裝裝載套件組合,那麼可能會遺漏 SDK (未偵測到 .NET Core SDK)。If the Hosting Bundle is installed after installing the 64-bit (x64) version of .NET Core, SDKs might appear to be missing (No .NET Core SDKs were detected). 若要解決此問題,請參閱 疑難排解 ASP.NET Core 專案To resolve the problem, see 疑難排解 ASP.NET Core 專案.

直接下載 (目前版本)Direct download (current version)

使用下列連結下載安裝程式:Download the installer using the following link:

目前的 .NET Core 裝載套件組合安裝程式 (直接下載)Current .NET Core Hosting Bundle installer (direct download)

安裝程式的先前版本Earlier versions of the installer

若要取得安裝程式的先前版本:To obtain an earlier version of the installer:

  1. 瀏覽至 .NET 下載封存Navigate to the .NET download archives.
  2. 在 [.NET Core] 下,選取 .NET Core 版本。Under .NET Core, select the .NET Core version.
  3. 在 [執行應用程式 - 執行階段] 欄中,尋找想要的 .NET Core 執行階段版本列。In the Run apps - Runtime column, find the row of the .NET Core runtime version desired.
  4. 使用執行階段與裝載套件組合連結。Download the installer using the Runtime & Hosting Bundle link.

警告

某些安裝程式包含已達到期生命週期結束 (EOL) 的發行版本,這些發行版本已不受 Microsoft 支援。Some installers contain release versions that have reached their end of life (EOL) and are no longer supported by Microsoft. 如需詳細資訊,請參閱支援原則 (英文 )。For more information, see the support policy.

安裝裝載套件組合Install the Hosting Bundle

  1. 在伺服器上執行安裝程式。Run the installer on the server. 從系統管理員命令殼層執行安裝程式時,有 下列參數可用:The following parameters are available when running the installer from an administrator command shell:

    • OPT_NO_ANCM=1 – 跳過安裝 ASP.NET Core 模組。OPT_NO_ANCM=1 – Skip installing the ASP.NET Core Module.
    • OPT_NO_RUNTIME=1 – 跳過安裝 .NET Core 執行階段。OPT_NO_RUNTIME=1 – Skip installing the .NET Core runtime.
    • OPT_NO_SHAREDFX=1 – 跳過安裝 ASP.NET 共用架構 (ASP.NET 執行階段)。OPT_NO_SHAREDFX=1 – Skip installing the ASP.NET Shared Framework (ASP.NET runtime).
    • OPT_NO_X86=1 – 跳過安裝 x86 執行階段。OPT_NO_X86=1 – Skip installing x86 runtimes. 當您確定不會裝載 32 位元應用程式時,請使用此參數。Use this parameter when you know that you won't be hosting 32-bit apps. 如果將來有可能同時裝載 32 位元和 64 位元應用程式,請不要使用此參數並安裝這兩個執行階段。If there's any chance that you will host both 32-bit and 64-bit apps in the future, don't use this parameter and install both runtimes.
    • OPT_NO_SHARED_CONFIG_CHECK=1 – 停用使用 IIS 共用設定 (當共用設定 (applicationHost.config) 位於與 IIS 安裝相同的機器上時) 進行檢查。OPT_NO_SHARED_CONFIG_CHECK=1 – Disable the check for using an IIS Shared Configuration when the shared configuration (applicationHost.config) is on the same machine as the IIS installation. 只在 ASP.NET Core 2.2 或更新版本的裝載套件組合安裝程式上可用。Only available for ASP.NET Core 2.2 or later Hosting Bundler installers. 如需詳細資訊,請參閱 ASP.NET Core 模組For more information, see ASP.NET Core 模組.
  2. 請重新啟動系統,或是從命令殼層依序執行 net stop was /ynet start w3svcRestart the system or execute net stop was /y, followed by net start w3svc from a command shell. 重新啟動 IIS 將能偵測到由安裝程式對系統路徑 (此為環境變數) 所做出的變更。Restarting IIS picks up a change to the system PATH, which is an environment variable, made by the installer.

注意

如需 IIS 共用組態的資訊,請參閱使用 IIS 共用組態的 ASP.NET Core 模組For information on IIS Shared Configuration, see ASP.NET Core Module with IIS Shared Configuration.

使用 Visual Studio 發佈時安裝 Web DeployInstall Web Deploy when publishing with Visual Studio

將應用程式部署到具有 Web Deploy 的伺服器時,請在伺服器上安裝最新版的 Web Deploy。When deploying apps to servers with Web Deploy, install the latest version of Web Deploy on the server. 若要安裝 Web Deploy,請使用 Web Platform Installer (WebPI) 或從 Microsoft 下載中心直接取得安裝程式。To install Web Deploy, use the Web Platform Installer (WebPI) or obtain an installer directly from the Microsoft Download Center. 慣用的方法是使用 WebPI。The preferred method is to use WebPI. WebPI 提供獨立的安裝程式和組態以裝載提供者。WebPI offers a standalone setup and a configuration for hosting providers.

建立 IIS 網站Create the IIS site

  1. 在主控系統上,請建立資料夾以容納應用程式的已發行資料夾和檔案。On the hosting system, create a folder to contain the app's published folders and files. 在下列步驟中,您提供資料夾路徑給 IIS,作為應用程式的實體路徑。In a following step, the folder's path is provided to IIS as the physical path to the app. 如需應用程式之部署資料夾和檔案配置的詳細資訊,請參閱 ASP.NET Core 目錄結構For more information on an app's deployment folder and file layout, see ASP.NET Core 目錄結構.

  2. 在 [IIS 管理員] 中,於 [連線] 面板中開啟伺服器的節點。In IIS Manager, open the server's node in the Connections panel. 以滑鼠右鍵按一下 [網站] 資料夾。Right-click the Sites folder. 從操作功能表選取 [新增網站] 。Select Add Website from the contextual menu.

  3. 提供網站名稱,並將實體路徑設定為應用程式的部署資料夾。Provide a Site name and set the Physical path to the app's deployment folder. 透過選取 [確定] 來提供繫結設定並建立網站:Provide the Binding configuration and create the website by selecting OK:

    在新增網站步驟中提供站台名稱、實體路徑和主機名稱。

    警告

    使用最上層萬用字元繫結 (http://*:80/http://+:80)。Top-level wildcard bindings (http://*:80/ and http://+:80) should not be used. 最上層萬用字元繫結可能暴露您的應用程式安全性弱點。Top-level wildcard bindings can open up your app to security vulnerabilities. 這對強式與弱式萬用字元皆適用。This applies to both strong and weak wildcards. 請使用明確主機名稱,而非萬用字元。Use explicit host names rather than wildcards. 若您擁有整個父網域 (與具弱點的 *.com 相對) 的控制權,則子網域萬用字元繫結 (例如 *.mysub.com) 就沒有此安全性風險。Subdomain wildcard binding (for example, *.mysub.com) doesn't have this security risk if you control the entire parent domain (as opposed to *.com, which is vulnerable). 如需詳細資訊,請參閱 rfc7230 5.4 節See rfc7230 section-5.4 for more information.

  4. 在伺服器的節點之下,選取 [應用程式集區] 。Under the server's node, select Application Pools.

  5. 以滑鼠右鍵按一下網站的應用程式集區,然後從操作功能表選取 [基本設定] 。Right-click the site's app pool and select Basic Settings from the contextual menu.

  6. 在 [編輯應用程式集區] 視窗中,將 [.NET CLR 版本] 設定為 [沒有受控碼] :In the Edit Application Pool window, set the .NET CLR version to No Managed Code:

    將 .NET CLR 版本設為 [沒有受控碼]。

    ASP.NET Core 會在不同的處理序中執行,並管理執行階段。ASP.NET Core runs in a separate process and manages the runtime. ASP.NET Core 不仰賴載入桌面 CLR (.NET CLR)—會使用 .NET Core 的核心通用語言執行平台 (CoreCLR) 來開機以在背景工作處理序中裝載應用程式。ASP.NET Core doesn't rely on loading the desktop CLR (.NET CLR)—the Core Common Language Runtime (CoreCLR) for .NET Core is booted to host the app in the worker process. 將 [.NET CLR 版本] 設定為 [沒有受控碼] 是選擇性的,但建議這樣做。Setting the .NET CLR version to No Managed Code is optional but recommended.

  7. ASP.NET Core 2.2 或更新版本:對於使用同處理序主控模型的 64 位元 (x64) 自封式部署,會停用 32 位元 (x86) 處理序的應用程式集區。ASP.NET Core 2.2 or later: For a 64-bit (x64) self-contained deployment that uses the in-process hosting model, disable the app pool for 32-bit (x86) processes.

    在 IIS 管理員的 [動作] 資訊看板 > [應用程式集區] 中,選取 [設定應用程式集區預設值] 或 [進階設定] 。In the Actions sidebar of IIS Manager > Application Pools, select Set Application Pool Defaults or Advanced Settings. 找到 [啟用 32 位元應用程式] ,然後將其值設定為 FalseLocate Enable 32-Bit Applications and set the value to False. 此設定不會影響為處理程序外裝載部署的應用程式。This setting doesn't affect apps deployed for out-of-process hosting.

  8. 確認處理序模型身分識別具有適當的權限。Confirm the process model identity has the proper permissions.

    如果您將應用程式集區的預設身分識別 ([處理序模型] > [身分識別] ) 從 ApplicationPoolIdentity 變更為其他身分識別,請確認新的身分識別具有必要權限,可存取應用程式的資料夾、資料庫和其他必要的資源。If the default identity of the app pool (Process Model > Identity) is changed from ApplicationPoolIdentity to another identity, verify that the new identity has the required permissions to access the app's folder, database, and other required resources. 例如,應用程式集區需要針對應用程式讀取和寫入檔案的資料夾取得讀取和寫入權限。For example, the app pool requires read and write access to folders where the app reads and writes files.

Windows 驗證設定 (選擇性)Windows Authentication configuration (Optional)
如需詳細資訊,請參閱設定 Windows 驗證主題。For more information, see Configure Windows authentication.

部署應用程式Deploy the app

將應用程式部署至在建立 IIS 網站一節中所建立的 IIS 實體路徑資料夾。Deploy the app to the IIS Physical path folder that was established in the Create the IIS site section. Web Deploy 是建議的部署機制,但有數個選項可將應用程式從專案的 [publish] 資料夾移動至主機系統的部署資料夾。Web Deploy is the recommended mechanism for deployment, but several options exist for moving the app from the project's publish folder to the hosting system's deployment folder.

使用 Visual Studio 的 Web DeployWeb Deploy with Visual Studio

請參閱適用於 ASP.NET Core 應用程式部署的 Visual Studio 發行設定檔主題,了解如何建立搭配 Web Deploy 使用的發行設定檔。See the Visual Studio publish profiles for ASP.NET Core app deployment topic to learn how to create a publish profile for use with Web Deploy. 如果主機服務提供者提供或支援建立發行設定檔,請下載其設定檔,並使用 Visual Studio 的 [發行] 對話方塊匯入其設定檔:If the hosting provider provides a Publish Profile or support for creating one, download their profile and import it using the Visual Studio Publish dialog:

[發佈] 對話方塊頁

Visual Studio 外部的 Web DeployWeb Deploy outside of Visual Studio

透過命令列也可以在 Visual Studio 外部使用 Web DeployWeb Deploy can also be used outside of Visual Studio from the command line. 如需詳細資訊,請參閱 Web 部署工具For more information, see Web Deployment Tool.

Web Deploy 的替代項目Alternatives to Web Deploy

使用數種方法的其中一種將應用程式移到主機系統,例如手動複製、XcopyRobocopyPowerShellUse any of several methods to move the app to the hosting system, such as manual copy, Xcopy, Robocopy, or PowerShell.

如需 IIS 的 ASP.NET Core 部署詳細資訊,請參閱 IIS 系統管理員的部署資源一節。For more information on ASP.NET Core deployment to IIS, see the Deployment resources for IIS administrators section.

瀏覽網站Browse the website

應用程式部署到主機系統之後,請向其中一個應用程式的公用端點發出要求。After the app is deployed to the hosting system, make a request to one of the app's public endpoints.

在下列範例中,網站繫結至 IIS 上的連接埠 80,其主機名稱www.mysite.comIn the following example, the site is bound to an IIS Host name of www.mysite.com on Port 80. http://www.mysite.com 發出要求:A request is made to http://www.mysite.com:

Microsoft Edge 瀏覽器已載入 IIS 啟動頁面。

已鎖定的部署檔案Locked deployment files

當應用程式執行時,會鎖定部署資料夾中的檔案。Files in the deployment folder are locked when the app is running. 無法於部署期間覆寫已鎖定的檔案。Locked files can't be overwritten during deployment. 若要釋放部署中的已鎖定檔案,請使用下列其中一種方法停止應用程式集區:To release locked files in a deployment, stop the app pool using one of the following approaches:

  • 使用 Web Deploy 並參考專案檔中的 Microsoft.NET.Sdk.WebUse Web Deploy and reference Microsoft.NET.Sdk.Web in the project file. app_offline.htm 檔案是放在 Web 應用程式目錄的根目錄中。An app_offline.htm file is placed at the root of the web app directory. 當檔案存在時,ASP.NET Core 模組會正常關閉應用程式,並在部署期間提供 app_offline.htm 檔案。When the file is present, the ASP.NET Core Module gracefully shuts down the app and serves the app_offline.htm file during the deployment. 如需詳細資訊,請參閱 ASP.NET Core 模組組態參考For more information, see the ASP.NET Core Module configuration reference.

  • 在伺服器上的 IIS 管理員中手動停止應用程式集區。Manually stop the app pool in the IIS Manager on the server.

  • 使用 PowerShell 卸除 app_offline.html (需要 PowerShell 5 或更新版本):Use PowerShell to drop app_offline.html (requires PowerShell 5 or later):

    $pathToApp = 'PATH_TO_APP'
    
    # Stop the AppPool
    New-Item -Path $pathToApp app_offline.htm
    
    # Provide script commands here to deploy the app
    
    # Restart the AppPool
    Remove-Item -Path $pathToApp app_offline.htm
    
    

資料保護Data protection

ASP.NET Core 資料保護堆疊是由數個 ASP.NET Core 中介軟體所使用,包括用於驗證的中介軟體。The ASP.NET Core Data Protection stack is used by several ASP.NET Core middlewares, including middleware used in authentication. 即使資料保護 API 不是由使用者程式碼呼叫,仍應使用部署指令碼或是在使用者程式碼中設定資料保護,以建立持續性的密碼編譯金鑰存放區Even if Data Protection APIs aren't called by user code, data protection should be configured with a deployment script or in user code to create a persistent cryptographic key store. 如不設定資料保護,金鑰會保留在記憶體中,並於應用程式重新啟動時捨棄。If data protection isn't configured, the keys are held in memory and discarded when the app restarts.

如果 Keyring 儲存在記憶體中,則當應用程式重新啟動時:If the key ring is stored in memory when the app restarts:

  • 所有以 Cookie 為基礎的驗證權杖都會失效。All cookie-based authentication tokens are invalidated.
  • 當使用者提出下一個要求時,需要再次登入。Users are required to sign in again on their next request.
  • 所有以 Keyring 保護的資料都無法再解密。Any data protected with the key ring can no longer be decrypted. 這可能會包含 CSRF 權杖ASP.NET Core MVC TempData cookieThis may include CSRF tokens and ASP.NET Core MVC TempData cookies.

若要在 IIS 下設定資料保護以保存 Keyring,請使用下列其中一種方法:To configure data protection under IIS to persist the key ring, use one of the following approaches:

  • 建立資料保護登錄機碼Create Data Protection Registry Keys

    ASP.NET Core 應用程式所使用的資料保護金鑰會儲存在應用程式外部的登錄中。Data protection keys used by ASP.NET Core apps are stored in the registry external to the apps. 若要保存指定應用程式的金鑰,請為應用程式集區建立登錄機碼。To persist the keys for a given app, create registry keys for the app pool.

    若為獨立的非Web 伺服陣列 IIS 安裝,請針對搭配使用 ASP.NET Core 應用程式的每個應用程式集區,使用資料保護 Provision-AutoGenKeys.ps1 PowerShell 指令碼For standalone, non-webfarm IIS installations, the Data Protection Provision-AutoGenKeys.ps1 PowerShell script can be used for each app pool used with an ASP.NET Core app. 此指令碼會在 HKLM 登錄中建立登錄機碼,只有應用程式之應用程式集區的背景工作處理序帳戶可以存取它。This script creates a registry key in the HKLM registry that's accessible only to the worker process account of the app's app pool. 在待用期間使用 DPAPI 和全電腦金鑰加密金鑰。Keys are encrypted at rest using DPAPI with a machine-wide key.

    在 Web 伺服陣列案例中,應用程式可以設定成使用 UNC 路徑來儲存其資料保護 Keyring。In web farm scenarios, an app can be configured to use a UNC path to store its data protection key ring. 根據預設,資料保護金鑰不予加密。By default, the data protection keys aren't encrypted. 請確保網路共用的檔案權限僅限於執行應用程式的 Windows 帳戶。Ensure that the file permissions for the network share are limited to the Windows account the app runs under. 可以使用 X509 憑證來保護待用的金鑰。An X509 certificate can be used to protect keys at rest. 請考慮下列讓使用者上傳憑證的機制:將憑證放入使用者的受信任憑證存放區,並確保在執行使用者應用程式的所有電腦上都能使用這些憑證。Consider a mechanism to allow users to upload certificates: Place certificates into the user's trusted certificate store and ensure they're available on all machines where the user's app runs. 如需詳細資訊,請參閱設定 ASP.NET Core 資料保護See Configure ASP.NET Core Data Protection for details.

  • 設定 IIS 應用程式集區載入使用者設定檔Configure the IIS Application Pool to load the user profile

    此設定位在應用程式集區 [進階設定] 下的 [處理序模型] 區段中。This setting is in the Process Model section under the Advanced Settings for the app pool. 將 [載入使用者設定檔] 設為 TrueSet Load User Profile to True. 當設定為 True 時,金鑰會儲存在使用者設定檔目錄中,且使用具有使用者帳戶專屬金鑰的 DPAPI 保護。When set to True, keys are stored in the user profile directory and protected using DPAPI with a key specific to the user account. 金鑰會保存到 %LOCALAPPDATA%/ASP.NET/DataProtection-Keys 資料夾。Keys are persisted to the %LOCALAPPDATA%/ASP.NET/DataProtection-Keys folder.

    應用程式集區的 setProfileEnvironment 屬性也必須啟用。The app pool's setProfileEnvironment attribute must also be enabled. setProfileEnvironment 的預設值為 trueThe default value of setProfileEnvironment is true. 在某些情況下 (例如 Windows OS),setProfileEnvironment 會設為 falseIn some scenarios (for example, Windows OS), setProfileEnvironment is set to false. 如果金鑰並未如預期地儲存在使用者設定檔目錄中:If keys aren't stored in the user profile directory as expected:

    1. 瀏覽至 %windir%/system32/inetsrv/config 資料夾。Navigate to the %windir%/system32/inetsrv/config folder.
    2. 開啟 applicationHost.config 檔案。Open the applicationHost.config file.
    3. 找到 <system.applicationHost><applicationPools><applicationPoolDefaults><processModel> 項目。Locate the <system.applicationHost><applicationPools><applicationPoolDefaults><processModel> element.
    4. 確認 setProfileEnvironment 屬性不存在 (其預設值為 true),或明確地將屬性值設為 trueConfirm that the setProfileEnvironment attribute isn't present, which defaults the value to true, or explicitly set the attribute's value to true.
  • 將檔案系統當作 Keyring 存放區使用Use the file system as a key ring store

    調整應用程式程式碼,以將檔案系統當作 Keyring 存放區使用Adjust the app code to use the file system as a key ring store. 使用 X509 憑證來保護 Keyring,並確保憑證是受信任的憑證。Use an X509 certificate to protect the key ring and ensure the certificate is a trusted certificate. 如果憑證為自我簽署,請將憑證放在受信任的根存放區。If the certificate is self-signed, place the certificate in the Trusted Root store.

    在 Web 伺服陣列中使用 IIS 時:When using IIS in a web farm:

    • 請使用所有電腦都可以存取的檔案共用。Use a file share that all machines can access.
    • 將 X509 憑證部署到每一部電腦。Deploy an X509 certificate to each machine. 設定程式碼中的資料保護Configure data protection in code.
  • 設定資料保護的全電腦原則Set a machine-wide policy for data protection

    針對取用資料保護 API 的所有應用程式,資料保護系統僅支援有限的預設全電腦原則設定。The data protection system has limited support for setting a default machine-wide policy for all apps that consume the Data Protection APIs. 如需詳細資訊,請參閱ASP.NET Core 資料保護For more information, see ASP.NET Core 資料保護.

虛擬目錄Virtual Directories

ASP.NET Core 應用程式不支援 IIS 虛擬目錄IIS Virtual Directories aren't supported with ASP.NET Core apps. 應用程式能以子應用程式的形式裝載。An app can be hosted as a sub-application.

子應用程式Sub-applications

ASP.NET Core 應用程式能以 IIS 子應用程式的形式裝載。An ASP.NET Core app can be hosted as an IIS sub-application (sub-app). 子應用程式的路徑會成為根應用程式 URL 的一部分。The sub-app's path becomes part of the root app's URL.

子應用程式不應該包括 ASP.NET Core 模組做為處理常式。A sub-app shouldn't include the ASP.NET Core Module as a handler. 如果您在子應用程式的 web.config 檔案中將模組新增為處理常式,則嘗試瀏覽子應用程式時,會收到參考錯誤設定檔的 500.19 內部伺服器錯誤If the module is added as a handler in a sub-app's web.config file, a 500.19 Internal Server Error referencing the faulty config file is received when attempting to browse the sub-app.

下列範例顯示 ASP.NET Core 子應用程式的已發佈 web.config 檔案:The following example shows a published web.config file for an ASP.NET Core sub-app:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <aspNetCore processPath="dotnet" 
      arguments=".\MyApp.dll" 
      stdoutLogEnabled="false" 
      stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

在 ASP.NET Core 應用程式下裝載非 ASP.NET Core 子應用程式時,請明確移除子應用程式 web.config 檔案中已繼承的處理常式:When hosting a non-ASP.NET Core sub-app underneath an ASP.NET Core app, explicitly remove the inherited handler in the sub-app's web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <remove name="aspNetCore" />
    </handlers>
    <aspNetCore processPath="dotnet" 
      arguments=".\MyApp.dll" 
      stdoutLogEnabled="false" 
      stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

子應用程式內的靜態資產連結應該使用波狀符號與斜線 (~/) 標記法。Static asset links within the sub-app should use tilde-slash (~/) notation. 波狀符號與斜線標記法會觸發標記協助程式以將子應用程式的路徑基底附加到轉譯的相對連結前面。Tilde-slash notation triggers a Tag Helper to prepend the sub-app's pathbase to the rendered relative link. 針對位於 /subapp_path 的子應用程式,使用 src="~/image.png" 連結的影像會轉譯為 src="/subapp_path/image.png"For a sub-app at /subapp_path, an image linked with src="~/image.png" is rendered as src="/subapp_path/image.png". 根應用程式的靜態檔案中介軟體不會處理靜態檔案要求。The root app's Static File Middleware doesn't process the static file request. 要求會由子應用程式的靜態檔案中介軟體處理。The request is processed by the sub-app's Static File Middleware.

若靜態資產的 src 屬性是設定為絕對路徑 (例如,src="/image.png"),會以不使用子應用程式路徑基底的方式轉譯連結。If a static asset's src attribute is set to an absolute path (for example, src="/image.png"), the link is rendered without the sub-app's pathbase. 根應用程式的靜態檔案中介軟體會嘗試從根應用程式的 webroot 提供資產,這會導致「404 - 找不到」 回應 (除非根應用程式可存取靜態資產)。The root app's Static File Middleware attempts to serve the asset from the root app's web root, which results in a 404 - Not Found response unless the static asset is available from the root app.

裝載 ASP.NET Core 應用程式做為另一個 ASP.NET Core 應用程式下的子應用程式:To host an ASP.NET Core app as a sub-app under another ASP.NET Core app:

  1. 為子應用程式建立應用程式集區。Establish an app pool for the sub-app. 將 [.NET CLR 版本] 設定為 [沒有受控碼] ,因為會將核心通用語言執行平台 (CoreCLR) 開機以在背景工作處理序中裝載應用程式,而非在桌面 CLR (.NET CLR) 中裝載。Set the .NET CLR Version to No Managed Code because the Core Common Language Runtime (CoreCLR) for .NET Core is booted to host the app in the worker process, not the desktop CLR (.NET CLR).

  2. 使用根網站下資料夾中的子應用程式在 IIS 管理員中新增根網站。Add the root site in IIS Manager with the sub-app in a folder under the root site.

  3. 以滑鼠右鍵按一下 IIS 管理員中的子應用程式資料夾,然後選取 [轉換成應用程式] 。Right-click the sub-app folder in IIS Manager and select Convert to Application.

  4. 在 [新增應用程式] 對話方塊中,使用 [應用程式集區] 的[選取] 按鈕來指派您為子應用程式建立的應用程式集區。In the Add Application dialog, use the Select button for the Application Pool to assign the app pool that you created for the sub-app. 選取 [確定] 。Select OK.

將不同的應用程式集區指派給子應用程式是使用同處理序裝載模型。The assignment of a separate app pool to the sub-app is a requirement when using the in-process hosting model.

如需有關同處理序裝載模型與如何設定 ASP.NET Core 模組的詳細資訊,請參閱 ASP.NET Core 模組ASP.NET Core 模組For more information on the in-process hosting model and configuring the ASP.NET Core Module, see ASP.NET Core 模組 and ASP.NET Core 模組.

使用 web.config 的 IIS 組態Configuration of IIS with web.config

在對使用了 ASP.NET Core 模組的 ASP.NET Core 有作用的 IIS 情境下,設定會受 web.config<system.webServer> 區段影響。IIS configuration is influenced by the <system.webServer> section of web.config for IIS scenarios that are functional for ASP.NET Core apps with the ASP.NET Core Module. 舉例來說,IIS 設定對動態壓縮有作用。For example, IIS configuration is functional for dynamic compression. 如果在伺服器層級將 IIS 設為使用動態壓縮,應用程式 web.config 檔案中的 <urlCompression> 元素則可為 ASP.NET Core 應用程式予以停用。If IIS is configured at the server level to use dynamic compression, the <urlCompression> element in the app's web.config file can disable it for an ASP.NET Core app.

如需詳細資訊,請參閱 <system.webServer> 的設定參考ASP.NET Core 模組設定參考以及 IIS 模組與 ASP.NET CoreFor more information, see the configuration reference for <system.webServer>, ASP.NET Core Module Configuration Reference, and IIS Modules with ASP.NET Core. 若要設定在隔離的應用程式集區中執行之個別應用程式的環境變數 (支援 IIS 10.0 或更新版本),請參閱 IIS 參考文件之環境變數 <environmentVariables> 主題的 AppCmd.exe 命令一節。To set environment variables for individual apps running in isolated app pools (supported for IIS 10.0 or later), see the AppCmd.exe command section of the Environment Variables <environmentVariables> topic in the IIS reference documentation.

web.config 的組態區段Configuration sections of web.config

ASP.NET Core 應用程式的設定不使用 web.config 中 ASP.NET 4.x 應用程式的設定區段:Configuration sections of ASP.NET 4.x apps in web.config aren't used by ASP.NET Core apps for configuration:

  • <system.web>
  • <appSettings>
  • <connectionStrings>
  • <location>

使用其他組態提供者設定的 ASP.NET Core 應用程式。ASP.NET Core apps are configured using other configuration providers. 如需詳細資訊,請參閱組態For more information, see Configuration.

應用程式集區Application Pools

應用程式集區隔離取決於裝載模型:App pool isolation is determined by the hosting model:

  • 處理序內裝載 – 應用程式必須在分開的應用程式集區中執行。In-process hosting – Apps are required to run in separate app pools.
  • 處理序外裝載 – 建議藉由在各自的應用程式集區中執行每個應用程式,以將應用程式互相隔離。Out-of-process hosting – We recommend isolating the apps from each other by running each app in its own app pool.

IIS [新增網站] 對話方塊預設每個應用程式皆為單一應用程式集區。The IIS Add Website dialog defaults to a single app pool per app. 當提供 [網站名稱] 時,文字會自動轉移至 [應用程式集區] 文字方塊。When a Site name is provided, the text is automatically transferred to the Application pool textbox. 新增網站時,會使用該網站名稱建立新的應用程式集區。A new app pool is created using the site name when the site is added.

在伺服器上裝載多個網站時,建議您在其各自的應用程式集區中執行各個應用程式,讓應用程式彼此隔離。When hosting multiple websites on a server, we recommend isolating the apps from each other by running each app in its own app pool. IIS [新增網站] 對話方塊預設成此組態。The IIS Add Website dialog defaults to this configuration. 當提供 [網站名稱] 時,文字會自動轉移至 [應用程式集區] 文字方塊。When a Site name is provided, the text is automatically transferred to the Application pool textbox. 新增網站時,會使用該網站名稱建立新的應用程式集區。A new app pool is created using the site name when the site is added.

應用程式集區身分識別Application Pool Identity

應用程式集區身分識別帳戶可讓應用程式在唯一的帳戶下執行,不必建立及管理網域或本機帳戶。An app pool identity account allows an app to run under a unique account without having to create and manage domains or local accounts. 在 IIS 8.0 或更新版本中,IIS 管理背景工作處理序 (WAS) 會使用新的應用程式集區名稱建立虛擬帳戶,並預設在此帳戶下執行應用程式集區的背景工作處理序。On IIS 8.0 or later, the IIS Admin Worker Process (WAS) creates a virtual account with the name of the new app pool and runs the app pool's worker processes under this account by default. 在 IIS 管理主控台中,於應用程式集區的 [進階設定] 下,確定 [身分識別] 設定為使用 ApplicationPoolIdentityIn the IIS Management Console under Advanced Settings for the app pool, ensure that the Identity is set to use ApplicationPoolIdentity:

應用程式集區進階設定對話方塊

IIS 管理程序會在 Windows 安全系統中,以應用程式集區的名稱建立安全識別碼。The IIS management process creates a secure identifier with the name of the app pool in the Windows Security System. 可使用此身分識別來保護資源。Resources can be secured using this identity. 不過,此身分識別不是真正的使用者帳戶,也不會顯示在 Windows 使用者管理主控台中。However, this identity isn't a real user account and doesn't show up in the Windows User Management Console.

如果 IIS 背景工作處理序需要提升應用程式的存取權限,請修改包含應用程式的目錄存取控制清單 (ACL):If the IIS worker process requires elevated access to the app, modify the Access Control List (ACL) for the directory containing the app:

  1. 開啟 Windows 檔案總管,巡覽至目錄。Open Windows Explorer and navigate to the directory.

  2. 以滑鼠右鍵按一下目錄並選取 [屬性] 。Right-click on the directory and select Properties.

  3. 依序選取 [安全性] 索引標籤下的 [編輯] 按鈕和 [新增] 按鈕。Under the Security tab, select the Edit button and then the Add button.

  4. 選取 [位置] 按鈕,並確定選取系統。Select the Locations button and make sure the system is selected.

  5. 在 [輸入要選取的物件名稱] 區域中,輸入 IIS AppPool\<app_pool_name>Enter IIS AppPool\<app_pool_name> in Enter the object names to select area. 選取 [檢查名稱] 按鈕。Select the Check Names button. 針對 [DefaultAppPool] ,請使用 IIS AppPool\DefaultAppPool 檢查名稱。For the DefaultAppPool check the names using IIS AppPool\DefaultAppPool. 選取 [檢查名稱] 按鈕時,[DefaultAppPool] 的值便會顯示於物件名稱區域中。When the Check Names button is selected, a value of DefaultAppPool is indicated in the object names area. 您無法直接將應用程式集區名稱輸入至物件名稱區域。It isn't possible to enter the app pool name directly into the object names area. 檢查物件名稱時,請使用 IIS AppPool\<app_pool_name> 的格式。Use the IIS AppPool\<app_pool_name> format when checking for the object name.

    針對應用程式資料夾選取使用者或群組對話方塊:在選取 [檢查名稱] 之前,"DefaultAppPool" 這個應用程式集區名稱在物件名稱區域中會附加至 "IIS AppPool"。

  6. 選取 [確定] 。Select OK.

    針對應用程式資料夾選取使用者或群組對話方塊:選取 [檢查名稱] 之後,物件名稱 "DefaultAppPool" 會顯示在物件名稱區域中。

  7. 預設應該會授與讀取 & 執行權限。Read & execute permissions should be granted by default. 請視需要提供其他權限。Provide additional permissions as needed.

也可使用 ICACLS 工具透過命令提示字元授與存取權限。Access can also be granted at a command prompt using the ICACLS tool. 使用 DefaultAppPool作為範例,將會使用下列命令:Using the DefaultAppPool as an example, the following command is used:

ICACLS C:\sites\MyWebApp /grant "IIS AppPool\DefaultAppPool":F

如需詳細資訊,請參閱 icacls 主題。For more information, see the icacls topic.

HTTP/2 支援HTTP/2 support

在下列 IIS 部署案例中,ASP.NET Core 支援 HTTP/2HTTP/2 is supported with ASP.NET Core in the following IIS deployment scenarios:

  • 同處理序In-process
    • Windows Server 2016/Windows 10 或更新版本;IIS 10 或更新版本Windows Server 2016/Windows 10 or later; IIS 10 or later
    • TLS 1.2 或更新版本連線TLS 1.2 or later connection
  • 跨處理序Out-of-process
    • Windows Server 2016/Windows 10 或更新版本;IIS 10 或更新版本Windows Server 2016/Windows 10 or later; IIS 10 or later
    • 公開 Edge Server 連線使用 HTTP/2,但是對 Kestrel 伺服器的反向 Proxy 連線使用 HTTP/1.1。Public-facing edge server connections use HTTP/2, but the reverse proxy connection to the Kestrel server uses HTTP/1.1.
    • TLS 1.2 或更新版本連線TLS 1.2 or later connection

針對建立 HTTP/2 連線時的同處理序部署,HttpRequest.Protocol 會回報 HTTP/2For an in-process deployment when an HTTP/2 connection is established, HttpRequest.Protocol reports HTTP/2. 針對建立 HTTP/2 連線時的跨處理序部署,HttpRequest.Protocol 會回報 HTTP/1.1For an out-of-process deployment when an HTTP/2 connection is established, HttpRequest.Protocol reports HTTP/1.1.

如需有關同處理序和跨處理序主控模型的詳細資訊,請參閱 ASP.NET Core 模組For more information on the in-process and out-of-process hosting models, see ASP.NET Core 模組.

HTTP/2 支援符合下列基本需求的跨處理序部署:HTTP/2 is supported for out-of-process deployments that meet the following base requirements:

  • Windows Server 2016/Windows 10 或更新版本;IIS 10 或更新版本Windows Server 2016/Windows 10 or later; IIS 10 or later
  • 公開 Edge Server 連線使用 HTTP/2,但是對 Kestrel 伺服器的反向 Proxy 連線使用 HTTP/1.1。Public-facing edge server connections use HTTP/2, but the reverse proxy connection to the Kestrel server uses HTTP/1.1.
  • 目標 Framework:不適用於跨處理序部署,因為 HTTP/2 連線完全由 IIS 處理。Target framework: Not applicable to out-of-process deployments, since the HTTP/2 connection is handled entirely by IIS.
  • TLS 1.2 或更新版本連線TLS 1.2 or later connection

如果已建立 HTTP/2 連線,HttpRequest.Protocol 會報告 HTTP/1.1If an HTTP/2 connection is established, HttpRequest.Protocol reports HTTP/1.1.

HTTP/2 預設為啟用。HTTP/2 is enabled by default. 如果 HTTP/2 連線尚未建立,連線會退為 HTTP/1.1。Connections fall back to HTTP/1.1 if an HTTP/2 connection isn't established. 如需使用 IIS 部署之 HTTP/2 設定的詳細資訊,請參閱 IIS 上的 HTTP/2For more information on HTTP/2 configuration with IIS deployments, see HTTP/2 on IIS.

CORS 預檢要求CORS preflight requests

此節只適用於以 .NET Framework 為目標的 ASP.NET Core 應用程式。This section only applies to ASP.NET Core apps that target the .NET Framework.

針對以 .NET Framework 為目標的 ASP.NET Core 應用程式,在 IIS 中OPTIONS 要求預設不會傳遞到應用程式。For an ASP.NET Core app that targets the .NET Framework, OPTIONS requests aren't passed to the app by default in IIS. 若要了解如何在 web.config 中設定應用程式的 IIS 處理常式以傳遞 OPTIONS 要求,請參閱在 ASP.NET Web API 2 中啟用跨原始來源要求:CORS 如何運作To learn how to configure the app's IIS handlers in web.config to pass OPTIONS requests, see Enable cross-origin requests in ASP.NET Web API 2: How CORS Works.

應用程式初始化模組與閒置逾時Application Initialization Module and Idle Timeout

在 IIS 中由 ASP.NET Core 模組版本 2 裝載時:When hosted in IIS by the ASP.NET Core Module version 2:

應用程式初始化模組Application Initialization Module

套用到應用程式裝載同處理序與非同處理序。Applies to apps hosted in-process and out-of-process.

IIS 應用程式初始化是一項 IIS 功能,可在應用程式集區啟動或回收時,將 HTTP 要求傳送給應用程式。IIS Application Initialization is an IIS feature that sends an HTTP request to the app when the app pool starts or is recycled. 要求會觸發應用程式啟動。The request triggers the app to start. 根據預設,IIS 會發出應用程式根 URL (/) 的要求以初始化應用程式 (如需有關設定的詳細資訊,請參閱額外資源)。By default, IIS issues a request to the app's root URL (/) to initialize the app (see the additional resources for more details on configuration).

確認已啟用「IIS 應用程式初始化」角色功能:Confirm that the IIS Application Initialization role feature in enabled:

在 Windows 7 或更新的電腦系統上,當在本機使用 IIS 時:On Windows 7 or later desktop systems when using IIS locally:

  1. 瀏覽到 [控制台] > [程式] > [程式和功能] > [開啟或關閉 Windows 功能] (畫面左側)。Navigate to Control Panel > Programs > Programs and Features > Turn Windows features on or off (left side of the screen).
  2. 開啟 [網際網路資訊服務] > [World Wide Web 服務] > [應用程式開發功能] 。Open Internet Information Services > World Wide Web Services > Application Development Features.
  3. 選取 [應用程式初始化] 的核取方塊。Select the check box for Application Initialization.

在 Windows Server 2008 R2 或更新版本上:On Windows Server 2008 R2 or later:

  1. 開啟「新增角色與功能精靈」 。Open the Add Roles and Features Wizard.
  2. 在 [選取角色服務] 面板中,開啟 [應用程式開發] 節點。In the Select role services panel, open the Application Development node.
  3. 選取 [應用程式初始化] 的核取方塊。Select the check box for Application Initialization.

使用下列任一方式為網站啟用應用程式初始化模組:Use either of the following approaches to enable the Application Initialization Module for the site:

  • 使用 IIS 管理員:Using IIS Manager:

    1. 選取 [連線] 面板中的 [應用程式集區] 。Select Application Pools in the Connections panel.
    2. 以滑鼠右鍵按一下清單中應用程式的應用程式集區,然後選取 [進階設定] 。Right-click the app's app pool in the list and select Advanced Settings.
    3. 預設的 [啟動模式] 是 [OnDemand] 。The default Start Mode is OnDemand. 將 [啟動模式] 設定為 [AlwaysRunning] 。Set the Start Mode to AlwaysRunning. 選取 [確定] 。Select OK.
    4. 開啟 [連線] 面板中的 [站台] 節點。Open the Sites node in the Connections panel.
    5. 以滑鼠右鍵按一下應用程式,然後選取 [管理網站] > [進階設定] 。Right-click the app and select Manage Website > Advanced Settings.
    6. 預設 [預先載入已啟用] 設定是 [False] 。The default Preload Enabled setting is False. 將 [預先載入已啟用] 設定為 [True] 。Set Preload Enabled to True. 選取 [確定] 。Select OK.
  • 使用 web.config,新增 <applicationInitialization> 元素並將 doAppInitAfterRestart 設定為 true 至應用程式 web.config 檔案中的 <system.webServer> 元素:Using web.config, add the <applicationInitialization> element with doAppInitAfterRestart set to true to the <system.webServer> elements in the app's web.config file:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <location path="." inheritInChildApplications="false">
        <system.webServer>
          <applicationInitialization doAppInitAfterRestart="true" />
        </system.webServer>
      </location>
    </configuration>
    

閒置逾時Idle Timeout

僅適用於應用程式裝載同處理序。Only applies to apps hosted in-process.

若要防止應用程式閒置,請使用 IIS 管理員設定應用程式集區的閒置逾時:To prevent the app from idling, set the app pool's idle timeout using IIS Manager:

  1. 選取 [連線] 面板中的 [應用程式集區] 。Select Application Pools in the Connections panel.
  2. 以滑鼠右鍵按一下清單中應用程式的應用程式集區,然後選取 [進階設定] 。Right-click the app's app pool in the list and select Advanced Settings.
  3. 預設 [閒置逾時 (分鐘)] 是 20 分鐘。The default Idle Time-out (minutes) is 20 minutes. 將 [閒置逾時 (分鐘)] 設定為 0 (零)。Set the Idle Time-out (minutes) to 0 (zero). 選取 [確定] 。Select OK.
  4. 回收背景工作處理序。Recycle the worker process.

若要防止應用程式裝載非同處理序逾時,請使用下列任一方式:To prevent apps hosted out-of-process from timing out, use either of the following approaches:

應用程式初始化模組與閒置逾時額外資源Application Initialization Module and Idle Timeout additional resources

IIS 系統管理員的部署資源Deployment resources for IIS administrators

請參閱 IIS 文件以深入了解 IIS。Learn about IIS in-depth in the IIS documentation.
IIS 文件IIS documentation

了解 .NET Core 應用程式部署模型。Learn about .NET Core app deployment models.
.NET Core 應用程式部署.NET Core application deployment

了解 ASP.NET Core 模組如何讓 Kestrel Web 伺服器將 IIS 或 IIS Express 作為反向 Proxy 伺服器使用。Learn how the ASP.NET Core Module allows the Kestrel web server to use IIS or IIS Express as a reverse proxy server.
ASP.NET Core 模組ASP.NET Core Module

了解如何設定 ASP.NET Core 模組以裝載 ASP.NET Core 應用程式。Learn how to configure the ASP.NET Core Module for hosting ASP.NET Core apps.
ASP.NET Core 模組組態參考ASP.NET Core Module configuration reference

了解已發行之 ASP.NET Core 應用程式的目錄結構。Learn about the directory structure of published ASP.NET Core apps.
目錄結構Directory structure

探索 ASP.NET Core 應用程式的使用中和非使用中 IIS 模組,管理 IIS 模組的方式。Discover active and inactive IIS modules for ASP.NET Core apps and how to manage IIS modules.
IIS 模組IIS modules

了解如何診斷 ASP.NET Core 應用程式的 IIS 部署問題。Learn how to diagnose problems with IIS deployments of ASP.NET Core apps.
疑難排解Troubleshoot

區分在 IIS 上裝載 ASP.NET Core 應用程式時的常見錯誤。Distinguish common errors when hosting ASP.NET Core apps on IIS.
Azure App Service 和 IIS 常見的錯誤參考Common errors reference for Azure App Service and IIS

其他資源Additional resources