Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

HubConnection.On Method

Definition

Namespace:
Microsoft.AspNetCore.SignalR.Client
Assembly:
Microsoft.AspNetCore.SignalR.Client.Core.dll
Package:
Microsoft.AspNetCore.SignalR.Client.Core v10.0.0
Package:
Microsoft.AspNetCore.SignalR.Client.Core v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.SignalR.Client.Core v1.0.0
Package:
Microsoft.AspNetCore.SignalR.Client.Core v1.1.0
Package:
Microsoft.AspNetCore.SignalR.Client.Core v3.0.3
Package:
Microsoft.AspNetCore.SignalR.Client.Core v3.1.18
Package:
Microsoft.AspNetCore.SignalR.Client.Core v5.0.9
Package:
Microsoft.AspNetCore.SignalR.Client.Core v6.0.6
Package:
Microsoft.AspNetCore.SignalR.Client.Core v7.0.5
Package:
Microsoft.AspNetCore.SignalR.Client.Core v8.0.19
Package:
Microsoft.AspNetCore.SignalR.Client.Core v9.0.8

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Name Description
On(String, Type[], Func<Object[],Object,Task>, Object)

Registers a handler that will be invoked when the hub method with the specified method name is invoked.

On(String, Type[], Func<Object[],Object,Task<Object>>, Object)

Registers a handler that will be invoked when the hub method with the specified method name is invoked. Returns value returned by handler to server if the server requests a result.

On(String, Type[], Func<Object[],Object,Task>, Object)

Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs

Registers a handler that will be invoked when the hub method with the specified method name is invoked.

public:
 IDisposable ^ On(System::String ^ methodName, cli::array <Type ^> ^ parameterTypes, Func<cli::array <System::Object ^> ^, System::Object ^, System::Threading::Tasks::Task ^> ^ handler, System::Object ^ state);
public virtual IDisposable On(string methodName, Type[] parameterTypes, Func<object?[],object,System.Threading.Tasks.Task> handler, object state);
public IDisposable On(string methodName, Type[] parameterTypes, Func<object[],object,System.Threading.Tasks.Task> handler, object state);
abstract member On : string * Type[] * Func<obj[], obj, System.Threading.Tasks.Task> * obj -> IDisposable
override this.On : string * Type[] * Func<obj[], obj, System.Threading.Tasks.Task> * obj -> IDisposable
member this.On : string * Type[] * Func<obj[], obj, System.Threading.Tasks.Task> * obj -> IDisposable
Public Overridable Function On (methodName As String, parameterTypes As Type(), handler As Func(Of Object(), Object, Task), state As Object) As IDisposable
Public Function On (methodName As String, parameterTypes As Type(), handler As Func(Of Object(), Object, Task), state As Object) As IDisposable

Parameters

methodName
String

The name of the hub method to define.

parameterTypes
Type[]

The parameters types expected by the hub method.

handler
Func<Object[],Object,Task>

The handler that will be raised when the hub method is invoked.

state
Object

A state object that will be passed to the handler.

Returns

A subscription that can be disposed to unsubscribe from the hub method.

Remarks

This is a low level method for registering a handler. Using an HubConnectionExtensionsOn extension method is recommended.

Applies to

On(String, Type[], Func<Object[],Object,Task<Object>>, Object)

Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs

Registers a handler that will be invoked when the hub method with the specified method name is invoked. Returns value returned by handler to server if the server requests a result.

public virtual IDisposable On(string methodName, Type[] parameterTypes, Func<object?[],object,System.Threading.Tasks.Task<object?>> handler, object state);
abstract member On : string * Type[] * Func<obj[], obj, System.Threading.Tasks.Task<obj>> * obj -> IDisposable
override this.On : string * Type[] * Func<obj[], obj, System.Threading.Tasks.Task<obj>> * obj -> IDisposable
Public Overridable Function On (methodName As String, parameterTypes As Type(), handler As Func(Of Object(), Object, Task(Of Object)), state As Object) As IDisposable

Parameters

methodName
String

The name of the hub method to define.

parameterTypes
Type[]

The parameters types expected by the hub method.

handler
Func<Object[],Object,Task<Object>>

The handler that will be raised when the hub method is invoked.

state
Object

A state object that will be passed to the handler.

Returns

A subscription that can be disposed to unsubscribe from the hub method.

Remarks

This is a low level method for registering a handler. Using an HubConnectionExtensionsOn extension method is recommended.

Applies to


Feedback

Was this page helpful?