IWebHostBuilder 介面

定義

IWebHost 產生器。

public interface class IWebHostBuilder
public interface IWebHostBuilder
type IWebHostBuilder = interface
Public Interface IWebHostBuilder
衍生

方法

Build()

IWebHost建置裝載 Web 應用程式的 。

ConfigureAppConfiguration(Action<WebHostBuilderContext,IConfigurationBuilder>)

加入用來設定 的委派, IConfigurationBuilder 以建構 IConfiguration

ConfigureLogging(Action<ILoggerFactory>)

新增用於設定所提供 ILoggerFactory 的委派。 可能會多次呼叫此項。

ConfigureServices(Action<IServiceCollection>)

新增委派,以設定主機或 Web 應用程式的其他服務。 可能會多次呼叫此項。

ConfigureServices(Action<WebHostBuilderContext,IServiceCollection>)

新增委派,以設定主機或 Web 應用程式的其他服務。 可能會多次呼叫此項。

GetSetting(String)

從組態取得設定值。

UseLoggerFactory(ILoggerFactory)

ILoggerFactory指定 Web 主機要使用的 。

UseSetting(String, String)

在組態中新增或取代設定。

擴充方法

UseAzureAppServices(IWebHostBuilder)

設定應用程式以使用 Azure AppServices 整合。

CaptureStartupErrors(IWebHostBuilder, Boolean)

設定是否應該在 Web 主機的組態設定中擷取啟動錯誤。 啟用時,將會攔截啟動例外狀況,並傳回錯誤頁面。 如果停用,則會傳播啟動例外狀況。

PreferHostingUrls(IWebHostBuilder, Boolean)

指出主機是否應該接聽 在 上 IWebHostBuilder 設定的 URL,而不是在 上設定的 IServer URL。

Start(IWebHostBuilder, String[])

啟動 Web 主機,並在指定的 URL 上接聽。

SuppressStatusMessages(IWebHostBuilder, Boolean)

指定是否應該隱藏啟動狀態訊息。

UseConfiguration(IWebHostBuilder, IConfiguration)

在 Web 主機上使用指定的組態設定。

UseContentRoot(IWebHostBuilder, String)

指定 Web 主機要使用的內容根目錄。

UseEnvironment(IWebHostBuilder, String)

指定 Web 主機要使用的環境。

UseServer(IWebHostBuilder, IServer)

指定 Web 主機要使用的伺服器。

UseShutdownTimeout(IWebHostBuilder, TimeSpan)

指定等候 Web 主機關閉的時間量。

UseStartup(IWebHostBuilder, String)

指定元件,其中包含 Web 主機要使用的啟動類型。

UseUrls(IWebHostBuilder, String[])

指定 Web 主機將接聽的 URL。

UseWebRoot(IWebHostBuilder, String)

指定 Web 主機要使用的 Webroot 目錄。

ListenHttpOnAnyPort(IWebHostBuilder)

在指定的 HTTP 埠上加入接聽的 Kestrel 伺服器實例。

ListenHttpsOnAnyPort(IWebHostBuilder, X509Certificate2)

新增在隨機 HTTPS 埠上接聽的 Kestrel 伺服器實例。

UseFakeStartup(IWebHostBuilder)

新增空的 Startup 類別以滿足 ASP.NET 檢查。

Configure(IWebHostBuilder, Action<IApplicationBuilder>)

指定要用來設定 Web 應用程式的啟動方法。

Configure(IWebHostBuilder, Action<WebHostBuilderContext,IApplicationBuilder>)

指定要用來設定 Web 應用程式的啟動方法。

ConfigureAppConfiguration(IWebHostBuilder, Action<IConfigurationBuilder>)

加入用來設定 的委派, IConfigurationBuilder 以建構 IConfiguration

ConfigureLogging(IWebHostBuilder, Action<WebHostBuilderContext,ILoggingBuilder>)

新增用於設定所提供 LoggerFactory 的委派。 可能會多次呼叫此項。

ConfigureLogging(IWebHostBuilder, Action<ILoggingBuilder>)

新增用於設定所提供 ILoggingBuilder 的委派。 可能會多次呼叫此項。

UseDefaultServiceProvider(IWebHostBuilder, Action<WebHostBuilderContext,ServiceProviderOptions>)

設定預設服務提供者

UseDefaultServiceProvider(IWebHostBuilder, Action<ServiceProviderOptions>)

設定預設服務提供者

UseStartup(IWebHostBuilder, Type)

指定 Web 主機要使用的啟動類型。

UseStartup<TStartup>(IWebHostBuilder)

指定 Web 主機要使用的啟動類型。

UseStartup<TStartup>(IWebHostBuilder, Func<WebHostBuilderContext,TStartup>)

指定處理站,以建立 Web 主機要使用的啟動實例。

UseStaticWebAssets(IWebHostBuilder)

WebRootFileProvider 設定為使用參考專案和套件所定義的靜態 Web 資產。

UseHttpSys(IWebHostBuilder)

將 Http.sys 指定為 Web 主機要使用的伺服器。

UseHttpSys(IWebHostBuilder, Action<HttpSysOptions>)

將 Http.sys 指定為 Web 主機要使用的伺服器。

UseIIS(IWebHostBuilder)

設定伺服器在 AspNetCoreModule 後方執行時應該接聽的埠和基底路徑。 應用程式也會設定為擷取啟動錯誤。

UseIISIntegration(IWebHostBuilder)

設定伺服器在 AspNetCoreModule 後方執行時應該接聽的埠和基底路徑。 應用程式也會設定為擷取啟動錯誤。

ConfigureKestrel(IWebHostBuilder, Action<WebHostBuilderContext,KestrelServerOptions>)

設定 Kestrel 選項,但未註冊 IServer。 請參閱 UseKestrel(IWebHostBuilder)

ConfigureKestrel(IWebHostBuilder, Action<KestrelServerOptions>)

設定 Kestrel 選項,但未註冊 IServer。 請參閱 UseKestrel(IWebHostBuilder)

UseKestrel(IWebHostBuilder)

將 Kestrel 指定為 Web 主機要使用的伺服器。

UseKestrel(IWebHostBuilder, Action<WebHostBuilderContext,KestrelServerOptions>)

將 Kestrel 指定為 Web 主機要使用的伺服器。

UseKestrel(IWebHostBuilder, Action<KestrelServerOptions>)

將 Kestrel 指定為 Web 主機要使用的伺服器。

UseKestrel(IWebHostBuilder, Action<KestrelServerOptions>)

將 Kestrel 指定為 Web 主機要使用的伺服器。

UseKestrelCore(IWebHostBuilder)

將 Kestrel 指定為 Web 主機要使用的伺服器。 包含的自動功能比 UseKestrel(IWebHostBuilder) 修剪更有效率 (,例如原生 AOT 案例) 。 如果主機最終會視某些不存在的功能而定,將會嘗試視需要啟用它。 失敗,當主機啟動時,將會引發具有資訊性錯誤訊息的例外狀況。

UseKestrelHttpsConfiguration(IWebHostBuilder)

在案例中 UseKestrelCore(IWebHostBuilder) ,可能需要明確加入宣告特定 HTTPS 功能。 例如,如果 ASPNETCORE_URLS 包含 https:// 位址, UseKestrelHttpsConfiguration(IWebHostBuilder) 將會在該端點上啟用 HTTPS 的設定。

在案例中 UseKestrel(IWebHostBuilder) 沒有任何作用。

UseLibuv(IWebHostBuilder)
已淘汰.

將 Libuv 指定為 Kestrel 要使用的傳輸。

UseLibuv(IWebHostBuilder, Action<LibuvTransportOptions>)
已淘汰.

將 Libuv 指定為 Kestrel 要使用的傳輸。

UseQuic(IWebHostBuilder)

IWebHost 產生器。

UseQuic(IWebHostBuilder, Action<QuicTransportOptions>)

IWebHost 產生器。

UseNamedPipes(IWebHostBuilder)

將具名管道指定為 Kestrel 要使用的傳輸。

UseNamedPipes(IWebHostBuilder, Action<NamedPipeTransportOptions>)

將具名管道指定為 Kestrel 要使用的傳輸。

UseQuic(IWebHostBuilder)

將 Quic 指定為 Kestrel 要使用的傳輸。

UseQuic(IWebHostBuilder, Action<QuicTransportOptions>)

將 Quic 指定為 Kestrel 要使用的傳輸。

UseSockets(IWebHostBuilder)

將 Sockets 指定為 Kestrel 要使用的傳輸。

UseSockets(IWebHostBuilder, Action<SocketTransportOptions>)

將 Sockets 指定為 Kestrel 要使用的傳輸。

UseWebListener(IWebHostBuilder)

將 WebListener 指定為 Web 主機要使用的伺服器。

UseWebListener(IWebHostBuilder, Action<WebListenerOptions>)

將 WebListener 指定為 Web 主機要使用的伺服器。

ConfigureTestContainer<TContainer>(IWebHostBuilder, Action<TContainer>)

使用 中 servicesConfiguration 所提供的服務來設定 IWebHostBuilder 實例。

ConfigureTestServices(IWebHostBuilder, Action<IServiceCollection>)

使用 中 servicesConfiguration 所提供的服務來設定 IWebHostBuilder 實例。

UseSolutionRelativeContentRoot(IWebHostBuilder, String, String)

設定 的內容根目錄相對於 solutionRelativePath

UseSolutionRelativeContentRoot(IWebHostBuilder, String, String, String)

設定 的內容根目錄相對於 solutionRelativePath

UseTestServer(IWebHostBuilder)

TestServer啟用服務。

UseTestServer(IWebHostBuilder, Action<TestServerOptions>)

TestServer啟用服務。

適用於