Share via


ConnectionBuilderExtensions.Use Method

Definition

Overloads

Use(IConnectionBuilder, Func<ConnectionContext,ConnectionDelegate,Task>)

Add the given middleware to the connection. If you aren't calling the next function, use Run(IConnectionBuilder, Func<ConnectionContext,Task>) instead.

Use(IConnectionBuilder, Func<ConnectionContext,Func<Task>,Task>)

Add the given middleware to the connection. If you aren't calling the next function, use Run(IConnectionBuilder, Func<ConnectionContext,Task>) instead.

Prefer using Use(IConnectionBuilder, Func<ConnectionContext,ConnectionDelegate,Task>) for better performance as shown below:

builder.Use((context, next) =>
{
    return next(context);
});

Use(IConnectionBuilder, Func<ConnectionContext,ConnectionDelegate,Task>)

Source:
ConnectionBuilderExtensions.cs
Source:
ConnectionBuilderExtensions.cs

Add the given middleware to the connection. If you aren't calling the next function, use Run(IConnectionBuilder, Func<ConnectionContext,Task>) instead.

public static Microsoft.AspNetCore.Connections.IConnectionBuilder Use (this Microsoft.AspNetCore.Connections.IConnectionBuilder connectionBuilder, Func<Microsoft.AspNetCore.Connections.ConnectionContext,Microsoft.AspNetCore.Connections.ConnectionDelegate,System.Threading.Tasks.Task> middleware);
static member Use : Microsoft.AspNetCore.Connections.IConnectionBuilder * Func<Microsoft.AspNetCore.Connections.ConnectionContext, Microsoft.AspNetCore.Connections.ConnectionDelegate, System.Threading.Tasks.Task> -> Microsoft.AspNetCore.Connections.IConnectionBuilder
<Extension()>
Public Function Use (connectionBuilder As IConnectionBuilder, middleware As Func(Of ConnectionContext, ConnectionDelegate, Task)) As IConnectionBuilder

Parameters

connectionBuilder
IConnectionBuilder

The IConnectionBuilder.

middleware
Func<ConnectionContext,ConnectionDelegate,Task>

The middleware to add to the IConnectionBuilder.

Returns

The IConnectionBuilder.

Applies to

Use(IConnectionBuilder, Func<ConnectionContext,Func<Task>,Task>)

Source:
ConnectionBuilderExtensions.cs
Source:
ConnectionBuilderExtensions.cs
Source:
ConnectionBuilderExtensions.cs
Source:
ConnectionBuilderExtensions.cs
Source:
ConnectionBuilderExtensions.cs
Source:
ConnectionBuilderExtensions.cs
Source:
ConnectionBuilderExtensions.cs
Source:
ConnectionBuilderExtensions.cs
Source:
ConnectionBuilderExtensions.cs

Add the given middleware to the connection. If you aren't calling the next function, use Run(IConnectionBuilder, Func<ConnectionContext,Task>) instead.

Prefer using Use(IConnectionBuilder, Func<ConnectionContext,ConnectionDelegate,Task>) for better performance as shown below:

builder.Use((context, next) =>
{
    return next(context);
});

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Connections::IConnectionBuilder ^ Use(Microsoft::AspNetCore::Connections::IConnectionBuilder ^ connectionBuilder, Func<Microsoft::AspNetCore::Connections::ConnectionContext ^, Func<System::Threading::Tasks::Task ^> ^, System::Threading::Tasks::Task ^> ^ middleware);
public static Microsoft.AspNetCore.Connections.IConnectionBuilder Use (this Microsoft.AspNetCore.Connections.IConnectionBuilder connectionBuilder, Func<Microsoft.AspNetCore.Connections.ConnectionContext,Func<System.Threading.Tasks.Task>,System.Threading.Tasks.Task> middleware);
static member Use : Microsoft.AspNetCore.Connections.IConnectionBuilder * Func<Microsoft.AspNetCore.Connections.ConnectionContext, Func<System.Threading.Tasks.Task>, System.Threading.Tasks.Task> -> Microsoft.AspNetCore.Connections.IConnectionBuilder
<Extension()>
Public Function Use (connectionBuilder As IConnectionBuilder, middleware As Func(Of ConnectionContext, Func(Of Task), Task)) As IConnectionBuilder

Parameters

connectionBuilder
IConnectionBuilder

The IConnectionBuilder.

middleware
Func<ConnectionContext,Func<Task>,Task>

The middleware to add to the IConnectionBuilder.

Returns

The IConnectionBuilder.

Applies to