KestrunHttpMiddlewareExtensions.AddCors method (1 of 2)
Registers a named CORS policy that was already composed with a CorsPolicyBuilder and applies that policy in the pipeline.
public static KestrunHost AddCors(this KestrunHost host, string policyName,
Action<CorsPolicyBuilder> buildPolicy)
parameter | description |
---|---|
host | The KestrunHost instance to configure. |
policyName | The name to store/apply the policy under. |
buildPolicy | An action to configure the CORS policy. |
Return Value
The current KestrunHost instance.
Exceptions
exception | condition |
---|---|
ArgumentException | Thrown when the policy name is null or whitespace. |
See Also
- class KestrunHost
- class KestrunHttpMiddlewareExtensions
- namespace Kestrun.Hosting
KestrunHttpMiddlewareExtensions.AddCors method (2 of 2)
Registers a named CORS policy that was already composed with a CorsPolicyBuilder and applies that policy in the pipeline.
public static KestrunHost AddCors(this KestrunHost host, string policyName,
CorsPolicyBuilder builder)
parameter | description |
---|---|
host | The KestrunHost instance to configure. |
policyName | The name to store/apply the policy under. |
builder | A fully‑configured CorsPolicyBuilder. Callers typically chain .WithOrigins() , .WithMethods() , etc. before passing it here. |
See Also
- class KestrunHost
- class KestrunHttpMiddlewareExtensions
- namespace Kestrun.Hosting