Note

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

Access to this page requires authorization. You can try .

CookieExtensions.AddCookie Method

Definition

Namespace:
Microsoft.Extensions.DependencyInjection
Assembly:
Microsoft.AspNetCore.Authentication.Cookies.dll
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.Authentication.Cookies v2.0.0
Package:
Microsoft.AspNetCore.Authentication.Cookies v2.1.0
Package:
Microsoft.AspNetCore.Authentication.Cookies 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
AddCookie(AuthenticationBuilder)

Adds cookie authentication to AuthenticationBuilder using the default scheme. The default scheme is specified by AuthenticationScheme.

Cookie authentication uses a HTTP cookie persisted in the client to perform authentication.

AddCookie(AuthenticationBuilder, Action<CookieAuthenticationOptions>)

Adds cookie authentication to AuthenticationBuilder using the default scheme. The default scheme is specified by AuthenticationScheme.

Cookie authentication uses a HTTP cookie persisted in the client to perform authentication.

AddCookie(AuthenticationBuilder, String)

Adds cookie authentication to AuthenticationBuilder using the specified scheme.

Cookie authentication uses a HTTP cookie persisted in the client to perform authentication.

AddCookie(AuthenticationBuilder, String, Action<CookieAuthenticationOptions>)

Adds cookie authentication to AuthenticationBuilder using the specified scheme.

Cookie authentication uses a HTTP cookie persisted in the client to perform authentication.

AddCookie(AuthenticationBuilder, String, String, Action<CookieAuthenticationOptions>)

Adds cookie authentication to AuthenticationBuilder using the specified scheme.

Cookie authentication uses a HTTP cookie persisted in the client to perform authentication.

AddCookie(AuthenticationBuilder)

Source:
CookieExtensions.cs
Source:
CookieExtensions.cs
Source:
CookieExtensions.cs

Adds cookie authentication to AuthenticationBuilder using the default scheme. The default scheme is specified by AuthenticationScheme.

Cookie authentication uses a HTTP cookie persisted in the client to perform authentication.

public static Microsoft.AspNetCore.Authentication.AuthenticationBuilder AddCookie(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder);
static member AddCookie : Microsoft.AspNetCore.Authentication.AuthenticationBuilder -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
<Extension()>
Public Function AddCookie (builder As AuthenticationBuilder) As AuthenticationBuilder

Parameters

Returns

A reference to builder after the operation has completed.

Applies to

AddCookie(AuthenticationBuilder, Action<CookieAuthenticationOptions>)

Source:
CookieExtensions.cs
Source:
CookieExtensions.cs
Source:
CookieExtensions.cs

Adds cookie authentication to AuthenticationBuilder using the default scheme. The default scheme is specified by AuthenticationScheme.

Cookie authentication uses a HTTP cookie persisted in the client to perform authentication.

public static Microsoft.AspNetCore.Authentication.AuthenticationBuilder AddCookie(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, Action<Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions> configureOptions);
static member AddCookie : Microsoft.AspNetCore.Authentication.AuthenticationBuilder * Action<Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions> -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
<Extension()>
Public Function AddCookie (builder As AuthenticationBuilder, configureOptions As Action(Of CookieAuthenticationOptions)) As AuthenticationBuilder

Parameters

configureOptions
Action<CookieAuthenticationOptions>

A delegate to configure CookieAuthenticationOptions.

Returns

A reference to builder after the operation has completed.

Applies to

AddCookie(AuthenticationBuilder, String)

Source:
CookieExtensions.cs
Source:
CookieExtensions.cs
Source:
CookieExtensions.cs

Adds cookie authentication to AuthenticationBuilder using the specified scheme.

Cookie authentication uses a HTTP cookie persisted in the client to perform authentication.

public static Microsoft.AspNetCore.Authentication.AuthenticationBuilder AddCookie(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, string authenticationScheme);
static member AddCookie : Microsoft.AspNetCore.Authentication.AuthenticationBuilder * string -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
<Extension()>
Public Function AddCookie (builder As AuthenticationBuilder, authenticationScheme As String) As AuthenticationBuilder

Parameters

authenticationScheme
String

The authentication scheme.

Returns

A reference to builder after the operation has completed.

Applies to

AddCookie(AuthenticationBuilder, String, Action<CookieAuthenticationOptions>)

Source:
CookieExtensions.cs
Source:
CookieExtensions.cs
Source:
CookieExtensions.cs

Adds cookie authentication to AuthenticationBuilder using the specified scheme.

Cookie authentication uses a HTTP cookie persisted in the client to perform authentication.

public static Microsoft.AspNetCore.Authentication.AuthenticationBuilder AddCookie(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, string authenticationScheme, Action<Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions> configureOptions);
static member AddCookie : Microsoft.AspNetCore.Authentication.AuthenticationBuilder * string * Action<Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions> -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
<Extension()>
Public Function AddCookie (builder As AuthenticationBuilder, authenticationScheme As String, configureOptions As Action(Of CookieAuthenticationOptions)) As AuthenticationBuilder

Parameters

authenticationScheme
String

The authentication scheme.

configureOptions
Action<CookieAuthenticationOptions>

A delegate to configure CookieAuthenticationOptions.

Returns

A reference to builder after the operation has completed.

Applies to

AddCookie(AuthenticationBuilder, String, String, Action<CookieAuthenticationOptions>)

Source:
CookieExtensions.cs
Source:
CookieExtensions.cs
Source:
CookieExtensions.cs

Adds cookie authentication to AuthenticationBuilder using the specified scheme.

Cookie authentication uses a HTTP cookie persisted in the client to perform authentication.

public static Microsoft.AspNetCore.Authentication.AuthenticationBuilder AddCookie(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, string authenticationScheme, string? displayName, Action<Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions> configureOptions);
public static Microsoft.AspNetCore.Authentication.AuthenticationBuilder AddCookie(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions> configureOptions);
static member AddCookie : Microsoft.AspNetCore.Authentication.AuthenticationBuilder * string * string * Action<Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions> -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder
<Extension()>
Public Function AddCookie (builder As AuthenticationBuilder, authenticationScheme As String, displayName As String, configureOptions As Action(Of CookieAuthenticationOptions)) As AuthenticationBuilder

Parameters

authenticationScheme
String

The authentication scheme.

displayName
String

A display name for the authentication handler.

configureOptions
Action<CookieAuthenticationOptions>

A delegate to configure CookieAuthenticationOptions.

Returns

A reference to builder after the operation has completed.

Applies to


Feedback

Was this page helpful?