Note

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

Access to this page requires authorization. You can try .

CorsEndpointConventionBuilderExtensions.RequireCors Method

Definition

Namespace:
Microsoft.AspNetCore.Builder
Assembly:
Microsoft.AspNetCore.Cors.dll
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.App.Ref v8.0.19
Package:
Microsoft.AspNetCore.App.Ref v9.0.8
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

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
RequireCors<TBuilder>(TBuilder)

Adds a CORS policy with the default policy name to the endpoint(s).

RequireCors<TBuilder>(TBuilder, Action<CorsPolicyBuilder>)

Adds the specified CORS policy to the endpoint(s).

RequireCors<TBuilder>(TBuilder, String)

Adds a CORS policy with the specified name to the endpoint(s).

RequireCors<TBuilder>(TBuilder)

Source:
CorsEndpointConventionBuilderExtensions.cs

Adds a CORS policy with the default policy name to the endpoint(s).

public static TBuilder RequireCors<TBuilder>(this TBuilder builder) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder;
static member RequireCors : 'Builder -> 'Builder (requires 'Builder :> Microsoft.AspNetCore.Builder.IEndpointConventionBuilder)
<Extension()>
Public Function RequireCors(Of TBuilder As IEndpointConventionBuilder) (builder As TBuilder) As TBuilder

Type Parameters

TBuilder

Parameters

builder
TBuilder

The endpoint convention builder.

Returns

TBuilder

The original convention builder parameter.

Applies to

RequireCors<TBuilder>(TBuilder, Action<CorsPolicyBuilder>)

Source:
CorsEndpointConventionBuilderExtensions.cs

Adds the specified CORS policy to the endpoint(s).

public:
generic <typename TBuilder>
 where TBuilder : Microsoft::AspNetCore::Builder::IEndpointConventionBuilder[System::Runtime::CompilerServices::Extension]
 static TBuilder RequireCors(TBuilder builder, Action<Microsoft::AspNetCore::Cors::Infrastructure::CorsPolicyBuilder ^> ^ configurePolicy);
public static TBuilder RequireCors<TBuilder>(this TBuilder builder, Action<Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder> configurePolicy) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder;
static member RequireCors : 'Builder * Action<Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder> -> 'Builder (requires 'Builder :> Microsoft.AspNetCore.Builder.IEndpointConventionBuilder)
<Extension()>
Public Function RequireCors(Of TBuilder As IEndpointConventionBuilder) (builder As TBuilder, configurePolicy As Action(Of CorsPolicyBuilder)) As TBuilder

Type Parameters

TBuilder

Parameters

builder
TBuilder

The endpoint convention builder.

configurePolicy
Action<CorsPolicyBuilder>

A delegate which can use a policy builder to build a policy.

Returns

TBuilder

The original convention builder parameter.

Applies to

RequireCors<TBuilder>(TBuilder, String)

Source:
CorsEndpointConventionBuilderExtensions.cs

Adds a CORS policy with the specified name to the endpoint(s).

public:
generic <typename TBuilder>
 where TBuilder : Microsoft::AspNetCore::Builder::IEndpointConventionBuilder[System::Runtime::CompilerServices::Extension]
 static TBuilder RequireCors(TBuilder builder, System::String ^ policyName);
public static TBuilder RequireCors<TBuilder>(this TBuilder builder, string policyName) where TBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder;
static member RequireCors : 'Builder * string -> 'Builder (requires 'Builder :> Microsoft.AspNetCore.Builder.IEndpointConventionBuilder)
<Extension()>
Public Function RequireCors(Of TBuilder As IEndpointConventionBuilder) (builder As TBuilder, policyName As String) As TBuilder

Type Parameters

TBuilder

Parameters

builder
TBuilder

The endpoint convention builder.

policyName
String

The CORS policy name.

Returns

TBuilder

The original convention builder parameter.

Applies to


Feedback

Was this page helpful?