Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

WebHostBuilderExtensions.UseStartup Method

Definition

Namespace:
Microsoft.AspNetCore.Hosting
Assembly:
Microsoft.AspNetCore.Hosting.dll
Package:
Microsoft.AspNetCore.Hosting v1.0.0
Package:
Microsoft.AspNetCore.Hosting v1.1.0
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.Hosting v2.0.0
Package:
Microsoft.AspNetCore.Hosting v2.1.0
Package:
Microsoft.AspNetCore.Hosting v2.2.0
Package:
Microsoft.AspNetCore.App.Ref v3.0.1
Package:
Microsoft.AspNetCore.App.Ref v3.1.10
Package:
Microsoft.AspNetCore.App.Ref v5.0.0
Package:
Microsoft.AspNetCore.App.Ref v6.0.36
Package:
Microsoft.AspNetCore.App.Ref v7.0.5
Package:
Microsoft.AspNetCore.App.Ref v8.0.19
Package:
Microsoft.AspNetCore.App.Ref v9.0.8

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Name Description
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.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Hosting::IWebHostBuilder ^ UseStartup(Microsoft::AspNetCore::Hosting::IWebHostBuilder ^ hostBuilder, Type ^ startupType);
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseStartup(this Microsoft.AspNetCore.Hosting.IWebHostBuilder hostBuilder, Type startupType);
static member UseStartup : Microsoft.AspNetCore.Hosting.IWebHostBuilder * Type -> Microsoft.AspNetCore.Hosting.IWebHostBuilder
<Extension()>
Public Function UseStartup (hostBuilder As IWebHostBuilder, startupType As Type) As IWebHostBuilder

Parameters

hostBuilder
IWebHostBuilder

The IWebHostBuilder to configure.

startupType
Type

The Type to be used.

Returns

The IWebHostBuilder.

Applies to

UseStartup<TStartup>(IWebHostBuilder)

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

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

public:
generic <typename TStartup>
 where TStartup : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Hosting::IWebHostBuilder ^ UseStartup(Microsoft::AspNetCore::Hosting::IWebHostBuilder ^ hostBuilder);
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseStartup<TStartup>(this Microsoft.AspNetCore.Hosting.IWebHostBuilder hostBuilder) where TStartup : class;
static member UseStartup : Microsoft.AspNetCore.Hosting.IWebHostBuilder -> Microsoft.AspNetCore.Hosting.IWebHostBuilder (requires 'Startup : null)
<Extension()>
Public Function UseStartup(Of TStartup As Class) (hostBuilder As IWebHostBuilder) As IWebHostBuilder

Type Parameters

TStartup

The type containing the startup methods for the application.

Parameters

hostBuilder
IWebHostBuilder

The IWebHostBuilder to configure.

Returns

The IWebHostBuilder.

Applies to

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

Source:
WebHostBuilderExtensions.cs

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

public:
generic <typename TStartup>
 where TStartup : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Hosting::IWebHostBuilder ^ UseStartup(Microsoft::AspNetCore::Hosting::IWebHostBuilder ^ hostBuilder, Func<Microsoft::AspNetCore::Hosting::WebHostBuilderContext ^, TStartup> ^ startupFactory);
public static Microsoft.AspNetCore.Hosting.IWebHostBuilder UseStartup<TStartup>(this Microsoft.AspNetCore.Hosting.IWebHostBuilder hostBuilder, Func<Microsoft.AspNetCore.Hosting.WebHostBuilderContext,TStartup> startupFactory) where TStartup : class;
static member UseStartup : Microsoft.AspNetCore.Hosting.IWebHostBuilder * Func<Microsoft.AspNetCore.Hosting.WebHostBuilderContext, 'Startup (requires 'Startup : null)> -> Microsoft.AspNetCore.Hosting.IWebHostBuilder (requires 'Startup : null)
<Extension()>
Public Function UseStartup(Of TStartup As Class) (hostBuilder As IWebHostBuilder, startupFactory As Func(Of WebHostBuilderContext, TStartup)) As IWebHostBuilder

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


Feedback

Was this page helpful?