ภาษา

AgentHostExtensions.UseAgents(WebApplication, Boolean, Boolean) Method

Definition

Adds authentication and authorization middleware to the request pipeline.

public static Microsoft.AspNetCore.Builder.WebApplication UseAgents(this Microsoft.AspNetCore.Builder.WebApplication app, bool useRouting = false, bool useHeaderPropagation = true);
static member UseAgents : Microsoft.AspNetCore.Builder.WebApplication * bool * bool -> Microsoft.AspNetCore.Builder.WebApplication
<Extension()>
Public Function UseAgents (app As WebApplication, Optional useRouting As Boolean = false, Optional useHeaderPropagation As Boolean = true) As WebApplication

Parameters

app
WebApplication

The web application.

useRouting
Boolean

When true, calls app.UseRouting() before the authentication and authorization middleware. Routing is order dependent and must be added before authentication/authorization. Set this to false (the default) if routing is already configured elsewhere in the pipeline, otherwise it will be added twice.

useHeaderPropagation
Boolean

When true, calls app.UseHeaderPropagation() to enable header propagation middleware.

Returns

The same WebApplication for chaining.

Remarks

This calls app.UseAuthentication() and app.UseAuthorization() in the correct order. Call this before MapDefaultAgentEndpoints(IEndpointRouteBuilder, String).

If useRouting is true, app.UseRouting() is called first, since routing must be registered before authentication and authorization.

If you need to insert additional middleware between authentication and authorization (e.g., custom claims transformation), call UseAuthentication() and UseAuthorization() manually instead of using this method.

Applies to