Skip to content

IConnectionMiddleware Methods

Interface for connection middleware.

Implementers provide IConnectionMiddleware and invoke the supplied Microsoft.AspNetCore.Connections.ConnectionDelegate to continue the pipeline.

Middleware instances can be invoked concurrently for multiple connections. Per-connection state should be stored in local variables or on the Microsoft.AspNetCore.Connections.ConnectionContext.

Register via builder.UseMiddleware() or manually with builder.Use(next => ctx => middleware.OnConnectionAsync(ctx, next)).

OnConnectionAsync(ConnectionContext, ConnectionDelegate)

abstract
public abstract Task OnConnectionAsync(ConnectionContext context, ConnectionDelegate next)
Called when a connection is established. Implementations should call next to continue the pipeline after performing their work.

Parameters

contextConnectionContext
The connection context.
nextConnectionDelegate
The next delegate in the connection pipeline.