WebHostBuilderExtensions.UseStartup Method

Definition

Overloads

UseStartup(IWebHostBuilder, Type)

Specify the startup type to be used by the web host.

UseStartup<TStartup>(IWebHostBuilder)

Specify the startup type to be used by the web host.

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

Specify a factory that creates the startup instance to be used by the web host.

UseStartup(IWebHostBuilder, Type)

Source:
WebHostBuilderExtensions.cs
Source:
WebHostBuilderExtensions.cs
Source:
WebHostBuilderExtensions.cs

Specify the startup type to be used by the web host.

C#
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseStartup (this Microsoft.AspNetCore.Hosting.IWebHostBuilder hostBuilder, Type startupType);

Parameters

hostBuilder
IWebHostBuilder

The IWebHostBuilder to configure.

startupType
Type

The Type to be used.

Returns

The IWebHostBuilder.

Applies to

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

UseStartup<TStartup>(IWebHostBuilder)

Source:
WebHostBuilderExtensions.cs
Source:
WebHostBuilderExtensions.cs
Source:
WebHostBuilderExtensions.cs

Specify the startup type to be used by the web host.

C#
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseStartup<TStartup> (this Microsoft.AspNetCore.Hosting.IWebHostBuilder hostBuilder) where TStartup : class;

Type Parameters

TStartup

The type containing the startup methods for the application.

Parameters

hostBuilder
IWebHostBuilder

The IWebHostBuilder to configure.

Returns

The IWebHostBuilder.

Applies to

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

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

Source:
WebHostBuilderExtensions.cs

Specify a factory that creates the startup instance to be used by the web host.

C#
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseStartup<TStartup> (this Microsoft.AspNetCore.Hosting.IWebHostBuilder hostBuilder, Func<Microsoft.AspNetCore.Hosting.WebHostBuilderContext,TStartup> startupFactory) where TStartup : class;

Type Parameters

TStartup

Parameters

hostBuilder
IWebHostBuilder

The IWebHostBuilder to configure.

startupFactory
Func<WebHostBuilderContext,TStartup>

A delegate that specifies a factory for the startup class.

Returns

The IWebHostBuilder.

Remarks

When in a trimmed app, all public methods of TStartup are preserved. This should match the Startup type directly (and not a base type).

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 5.0, 6.0, 7.0, 8.0, 9.0