WebHostBuilder Class

A builder for Microsoft.AspNetCore.Hosting.IWebHost

Namespace
Microsoft.AspNetCore.Hosting
Assemblies
  • Microsoft.AspNetCore.Hosting

Syntax

public class WebHostBuilder : IWebHostBuilder
class Microsoft.AspNetCore.Hosting.WebHostBuilder

Constructors

WebHostBuilder()

Initializes a new instance of the Microsoft.AspNetCore.Hosting.WebHostBuilder class.

public WebHostBuilder()

Methods

Build()

Builds the required services and an Microsoft.AspNetCore.Hosting.IWebHost which hosts a web application.

Return type:Microsoft.AspNetCore.Hosting.IWebHost
public IWebHost Build()
ConfigureLogging(System.Action<Microsoft.Extensions.Logging.ILoggerFactory>)

Adds a delegate for configuring the provided Microsoft.Extensions.Logging.ILoggerFactory. This may be called multiple times.

Arguments:configureLogging (System.Action<Microsoft.Extensions.Logging.ILoggerFactory>) – The delegate that configures the Microsoft.Extensions.Logging.ILoggerFactory.
Return type:Microsoft.AspNetCore.Hosting.IWebHostBuilder
Returns:The Microsoft.AspNetCore.Hosting.IWebHostBuilder.
public IWebHostBuilder ConfigureLogging(Action<ILoggerFactory> configureLogging)
ConfigureServices(System.Action<Microsoft.Extensions.DependencyInjection.IServiceCollection>)

Adds a delegate for configuring additional services for the host or web application. This may be called multiple times.

Arguments:configureServices (System.Action<Microsoft.Extensions.DependencyInjection.IServiceCollection>) – A delegate for configuring the Microsoft.Extensions.DependencyInjection.IServiceCollection.
Return type:Microsoft.AspNetCore.Hosting.IWebHostBuilder
Returns:The Microsoft.AspNetCore.Hosting.IWebHostBuilder.
public IWebHostBuilder ConfigureServices(Action<IServiceCollection> configureServices)
GetSetting(System.String)

Get the setting value from the configuration.

Arguments:key (System.String) – The key of the setting to look up.
Return type:System.String
Returns:The value the setting currently contains.
public string GetSetting(string key)
UseLoggerFactory(Microsoft.Extensions.Logging.ILoggerFactory)

Specify the Microsoft.Extensions.Logging.ILoggerFactory to be used by the web host.

Arguments:loggerFactory (Microsoft.Extensions.Logging.ILoggerFactory) – The Microsoft.Extensions.Logging.ILoggerFactory to be used.
Return type:Microsoft.AspNetCore.Hosting.IWebHostBuilder
Returns:The Microsoft.AspNetCore.Hosting.IWebHostBuilder.
public IWebHostBuilder UseLoggerFactory(ILoggerFactory loggerFactory)
UseSetting(System.String, System.String)

Add or replace a setting in the configuration.

Arguments:
  • key (System.String) – The key of the setting to add or replace.
  • value (System.String) – The value of the setting to add or replace.
Return type:

Microsoft.AspNetCore.Hosting.IWebHostBuilder

Returns:

The Microsoft.AspNetCore.Hosting.IWebHostBuilder.

public IWebHostBuilder UseSetting(string key, string value)