Note

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

Access to this page requires authorization. You can try .

AuthenticationServiceCollectionExtensions.AddAuthentication Method

Definition

Namespace:
Microsoft.Extensions.DependencyInjection
Assembly:
Microsoft.AspNetCore.Authentication.dll
Package:
Microsoft.AspNetCore.Authentication v1.0.0
Package:
Microsoft.AspNetCore.Authentication 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.Authentication v2.0.0
Package:
Microsoft.AspNetCore.Authentication v2.1.0
Package:
Microsoft.AspNetCore.Authentication 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
AddAuthentication(IServiceCollection)

Registers services required by authentication services.

AddAuthentication(IServiceCollection, Action<AuthenticationOptions>)

Registers services required by authentication services and configures AuthenticationOptions.

AddAuthentication(IServiceCollection, Action<SharedAuthenticationOptions>)
AddAuthentication(IServiceCollection, String)

Registers services required by authentication services. defaultScheme specifies the name of the scheme to use by default when a specific scheme isn't requested.

AddAuthentication(IServiceCollection)

Source:
AuthenticationServiceCollectionExtensions.cs
Source:
AuthenticationServiceCollectionExtensions.cs
Source:
AuthenticationServiceCollectionExtensions.cs

Registers services required by authentication services.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
public static Microsoft.AspNetCore.Authentication.AuthenticationBuilder AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
static member AddAuthentication : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection
static member AddAuthentication : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
<Extension()>
Public Function AddAuthentication (services As IServiceCollection) As IServiceCollection
<Extension()>
Public Function AddAuthentication (services As IServiceCollection) As AuthenticationBuilder

Parameters

Returns

A AuthenticationBuilder that can be used to further configure authentication.

Applies to

AddAuthentication(IServiceCollection, Action<AuthenticationOptions>)

Source:
AuthenticationServiceCollectionExtensions.cs
Source:
AuthenticationServiceCollectionExtensions.cs
Source:
AuthenticationServiceCollectionExtensions.cs

Registers services required by authentication services and configures AuthenticationOptions.

public static Microsoft.AspNetCore.Authentication.AuthenticationBuilder AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.AspNetCore.Authentication.AuthenticationOptions> configureOptions);
static member AddAuthentication : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.AspNetCore.Authentication.AuthenticationOptions> -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
<Extension()>
Public Function AddAuthentication (services As IServiceCollection, configureOptions As Action(Of AuthenticationOptions)) As AuthenticationBuilder

Parameters

configureOptions
Action<AuthenticationOptions>

A delegate to configure AuthenticationOptions.

Returns

A AuthenticationBuilder that can be used to further configure authentication.

Applies to

AddAuthentication(IServiceCollection, Action<SharedAuthenticationOptions>)

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions> configureOptions);
static member AddAuthentication : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions> -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddAuthentication (services As IServiceCollection, configureOptions As Action(Of SharedAuthenticationOptions)) As IServiceCollection

Parameters

Returns

Applies to

AddAuthentication(IServiceCollection, String)

Source:
AuthenticationServiceCollectionExtensions.cs
Source:
AuthenticationServiceCollectionExtensions.cs
Source:
AuthenticationServiceCollectionExtensions.cs

Registers services required by authentication services. defaultScheme specifies the name of the scheme to use by default when a specific scheme isn't requested.

public static Microsoft.AspNetCore.Authentication.AuthenticationBuilder AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string defaultScheme);
static member AddAuthentication : Microsoft.Extensions.DependencyInjection.IServiceCollection * string -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
<Extension()>
Public Function AddAuthentication (services As IServiceCollection, defaultScheme As String) As AuthenticationBuilder

Parameters

defaultScheme
String

The default scheme used as a fallback for all other schemes.

Returns

A AuthenticationBuilder that can be used to further configure authentication.

Applies to


Feedback

Was this page helpful?