Note

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

Access to this page requires authorization. You can try .

IdentityServiceCollectionExtensions.AddIdentity Method

Definition

Namespace:
Microsoft.Extensions.DependencyInjection
Assembly:
Microsoft.AspNetCore.Identity.dll
Assemblies:
Microsoft.AspNetCore.Identity.dll, Microsoft.Extensions.Identity.Core.dll
Package:
Microsoft.AspNetCore.Identity v1.0.0
Package:
Microsoft.AspNetCore.Identity v1.1.0
Packages:
Microsoft.AspNetCore.App.Ref v10.0.0, Microsoft.Extensions.Identity.Core v10.0.0
Packages:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115, Microsoft.Extensions.Identity.Core v11.0.0-preview.4.26230.115
Packages:
Microsoft.AspNetCore.Identity v2.0.0, Microsoft.Extensions.Identity.Core v2.0.0
Packages:
Microsoft.AspNetCore.Identity v2.1.0, Microsoft.Extensions.Identity.Core v2.1.0
Packages:
Microsoft.AspNetCore.Identity v2.2.0, Microsoft.Extensions.Identity.Core v2.2.0
Packages:
Microsoft.AspNetCore.App.Ref v3.0.1, Microsoft.Extensions.Identity.Core v3.0.3
Packages:
Microsoft.AspNetCore.App.Ref v3.1.10, Microsoft.Extensions.Identity.Core v3.1.18
Packages:
Microsoft.AspNetCore.App.Ref v5.0.0, Microsoft.Extensions.Identity.Core v5.0.9
Packages:
Microsoft.AspNetCore.App.Ref v6.0.36, Microsoft.Extensions.Identity.Core v6.0.6
Packages:
Microsoft.AspNetCore.App.Ref v7.0.5, Microsoft.Extensions.Identity.Core v7.0.5
Packages:
Microsoft.AspNetCore.App.Ref v8.0.19, Microsoft.Extensions.Identity.Core v8.0.19
Packages:
Microsoft.AspNetCore.App.Ref v9.0.8, Microsoft.Extensions.Identity.Core 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
AddIdentity<TUser,TRole>(IServiceCollection)

Adds the default identity system configuration for the specified User and Role types.

AddIdentity<TUser,TRole>(IServiceCollection, Action<IdentityOptions>)
AddIdentity<TUser,TRole>(IServiceCollection, Action<IdentityOptions>)

Adds and configures the identity system for the specified User and Role types.

AddIdentity<TUser,TRole>(IServiceCollection)

Source:
IdentityServiceCollectionExtensions.cs
Source:
IdentityServiceCollectionExtensions.cs
Source:
IdentityServiceCollectionExtensions.cs

Adds the default identity system configuration for the specified User and Role types.

public static Microsoft.AspNetCore.Identity.IdentityBuilder AddIdentity<TUser,TRole>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where TUser : class where TRole : class;
static member AddIdentity : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.AspNetCore.Identity.IdentityBuilder (requires 'User : null and 'Role : null)
<Extension()>
Public Function AddIdentity(Of TUser As Class, TRole As Class) (services As IServiceCollection) As IdentityBuilder

Type Parameters

TUser

The type representing a User in the system.

TRole

The type representing a Role in the system.

Parameters

services
IServiceCollection

The services available in the application.

Returns

An IdentityBuilder for creating and configuring the identity system.

Applies to

AddIdentity<TUser,TRole>(IServiceCollection, Action<IdentityOptions>)

public static Microsoft.AspNetCore.Identity.IdentityBuilder AddIdentity<TUser,TRole>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.AspNetCore.Builder.IdentityOptions> setupAction) where TUser : class where TRole : class;
static member AddIdentity : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.AspNetCore.Builder.IdentityOptions> -> Microsoft.AspNetCore.Identity.IdentityBuilder (requires 'User : null and 'Role : null)
<Extension()>
Public Function AddIdentity(Of TUser As Class, TRole As Class) (services As IServiceCollection, setupAction As Action(Of IdentityOptions)) As IdentityBuilder

Type Parameters

TUser
TRole

Parameters

setupAction
Action<IdentityOptions>

Returns

Applies to

AddIdentity<TUser,TRole>(IServiceCollection, Action<IdentityOptions>)

Source:
IdentityServiceCollectionExtensions.cs
Source:
IdentityServiceCollectionExtensions.cs
Source:
IdentityServiceCollectionExtensions.cs

Adds and configures the identity system for the specified User and Role types.

public static Microsoft.AspNetCore.Identity.IdentityBuilder AddIdentity<TUser,TRole>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.AspNetCore.Identity.IdentityOptions> setupAction) where TUser : class where TRole : class;
static member AddIdentity : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.AspNetCore.Identity.IdentityOptions> -> Microsoft.AspNetCore.Identity.IdentityBuilder (requires 'User : null and 'Role : null)
<Extension()>
Public Function AddIdentity(Of TUser As Class, TRole As Class) (services As IServiceCollection, setupAction As Action(Of IdentityOptions)) As IdentityBuilder

Type Parameters

TUser

The type representing a User in the system.

TRole

The type representing a Role in the system.

Parameters

services
IServiceCollection

The services available in the application.

setupAction
Action<IdentityOptions>

An action to configure the IdentityOptions.

Returns

An IdentityBuilder for creating and configuring the identity system.

Applies to


Feedback

Was this page helpful?