Saltar al contenido
Esta página aún no está traducida.

CorsServiceCollectionExtensions Class

Shared CORS registration for the OIDC transport adapters. Every OIDC endpoint is tagged with the policy name CorsPolicyName (the MVC controllers through [EnableCors], the Minimal API endpoints through RequireCors); this fills that policy so a browser client can read the endpoints cross-origin out of the box, and leaves the host in full control of it.

C#
public static class CorsServiceCollectionExtensions

Inheritance System.Object → CorsServiceCollectionExtensions

Methods

CorsServiceCollectionExtensions.AddOidcCors(this IServiceCollection) Method

Registers the CORS services the OIDC endpoints rely on and a default CorsPolicyName policy built from OidcCorsOptions - but only when the host has not already defined a policy of that name. Idempotent: calling it from more than one adapter registers the post-configure step once and applies the default a single time.

C#
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddOidcCors(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);

Parameters

services Microsoft.Extensions.DependencyInjection.IServiceCollection

The service collection to add the CORS registration to.

Returns

Microsoft.Extensions.DependencyInjection.IServiceCollection
The same services instance so calls can be chained.