WebHost.CreateDefaultBuilder Method

Definition

Overloads

CreateDefaultBuilder()

Initializes a new instance of the WebHostBuilder class with pre-configured defaults.

CreateDefaultBuilder(String[])

Initializes a new instance of the WebHostBuilder class with pre-configured defaults.

CreateDefaultBuilder<TStartup>(String[])

Initializes a new instance of the WebHostBuilder class with pre-configured defaults using typed Startup.

CreateDefaultBuilder()

Source:
WebHost.cs
Source:
WebHost.cs
Source:
WebHost.cs

Initializes a new instance of the WebHostBuilder class with pre-configured defaults.

C#
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder CreateDefaultBuilder ();

Returns

The initialized IWebHostBuilder.

Remarks

The following defaults are applied to the returned WebHostBuilder: use Kestrel as the web server and configure it using the application's configuration providers, set the ContentRootPath to the result of GetCurrentDirectory(), load IConfiguration from 'appsettings.json' and 'appsettings.[EnvironmentName].json', load IConfiguration from User Secrets when EnvironmentName is 'Development' using the entry assembly, load IConfiguration from environment variables, configure the ILoggerFactory to log to the console and debug output, adds the HostFiltering middleware, adds the ForwardedHeaders middleware if ASPNETCORE_FORWARDEDHEADERS_ENABLED=true, and enable IIS integration.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

CreateDefaultBuilder(String[])

Source:
WebHost.cs
Source:
WebHost.cs
Source:
WebHost.cs

Initializes a new instance of the WebHostBuilder class with pre-configured defaults.

C#
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder CreateDefaultBuilder (string[] args);

Parameters

args
String[]

The command line args.

Returns

The initialized IWebHostBuilder.

Remarks

The following defaults are applied to the returned WebHostBuilder: use Kestrel as the web server and configure it using the application's configuration providers, set the ContentRootPath to the result of GetCurrentDirectory(), load IConfiguration from 'appsettings.json' and 'appsettings.[EnvironmentName].json', load IConfiguration from User Secrets when EnvironmentName is 'Development' using the entry assembly, load IConfiguration from environment variables, load IConfiguration from supplied command line args, configure the ILoggerFactory to log to the console and debug output, configure the WebRootFileProvider to map static web assets when EnvironmentName is 'Development' using the entry assembly, adds the HostFiltering middleware, adds the ForwardedHeaders middleware if ASPNETCORE_FORWARDEDHEADERS_ENABLED=true, and enable IIS integration.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

CreateDefaultBuilder<TStartup>(String[])

Source:
WebHost.cs
Source:
WebHost.cs
Source:
WebHost.cs

Initializes a new instance of the WebHostBuilder class with pre-configured defaults using typed Startup.

C#
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder CreateDefaultBuilder<TStartup> (string[] args) where TStartup : class;

Type Parameters

TStartup

The type containing the startup methods for the application.

Parameters

args
String[]

The command line args.

Returns

The initialized IWebHostBuilder.

Remarks

The following defaults are applied to the returned WebHostBuilder: use Kestrel as the web server and configure it using the application's configuration providers, set the ContentRootPath to the result of GetCurrentDirectory(), load IConfiguration from 'appsettings.json' and 'appsettings.[EnvironmentName].json', load IConfiguration from User Secrets when EnvironmentName is 'Development' using the entry assembly, load IConfiguration from environment variables, load IConfiguration from supplied command line args, configure the ILoggerFactory to log to the console and debug output, enable IIS integration.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0