Asp.net-Core-Mvc
MVC Core - UseIIS 和 UseIISIntegration 有什麼區別
查看程式碼,他們有相同的註釋,表明他們做同樣的事情:
/// <summary> /// Configures the port and base path the server should listen on when /// running behind AspNetCoreModule. The app will also be configured /// to capture startup errors. /// </summary>
UseIIS在Microsoft.AspNetCore.Server.IIS包裝中,而UseIISIntegration在Microsoft.AspNetCore.Server.IISIntegration.兩者有什麼區別?什麼時候需要使用其中一種?(或者兩者兼而有之?)
更新: github上有一個類似的問題,但那裡沒有有用的答案:https ://github.com/aspnet/AspNetCore/issues/6197
在 ASP.NET Core 2.2 之前,ASP.NET Core 託管在 IIS 中的程序外,這意味著我們有兩個應用程序程序:
w3wp.exe,IIS程序;和dotnet.exe,ASP.NET Core 程序,Kestrel Web 伺服器在此啟動。這意味著 IIS 和 Kestrel 在這兩個程序之間進行通信。
對於這種情況,您將使用
UseIISIntegration.ASP.NET Core 2.2 引入了程序內託管,您的 ASP.NET Core 應用程序在 IIS
w3wp.exe程序內執行,無需 Kestrel Web 伺服器,在這種情況下,您希望使用UseIIS.筆記:
- 官方文件似乎表明該
CreateDefaultBuilder方法會自行呼叫相應的方法;請參閱<https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.2#enable-the-iisintegration-components>- Rick Strahl 在以下部落格文章中提供了一些很好的圖表來顯示程序外和程序內託管之間的區別:https ://weblog.west-wind.com/posts/2019/Mar/16/ASPNET-Core -Hosting-on-IIS-with-ASPNET-Core-22