【问题标题】:ASP.NET Core and SignalR DocumentationASP.NET Core 和 SignalR 文档
【发布时间】:2020-04-26 02:04:01
【问题描述】:

在哪里可以找到 SignalR 的完整文档? 我该如何解决我的问题? 例如 - 我不知道这个方法是如何工作的

app.UseEndpoints(endpoint => endpoint.MapHub<ChatHub>("/chat"));

我怎样才能像其他方式一样调用此方法,而不是 lambda。

【问题讨论】:

标签: asp.net asp.net-core signalr


【解决方案1】:

为了避免 lambda,只需编写一个具有相同内容的函数,并将函数名称放在这里。

在你的情况下,为了避免 lambda:

app.UseEndpoints(endpoint => endpoint.MapHub<ChatHub>("/chat"));

改成

// Start up.cs begin
using Microsoft.AspNetCore.Builder;

// Put this somewhere in your StartUp class
public void OnEndpointConfigure(IEndpointRouteBuilder endpoint)
{
    endpoint.MapHub<ChatHub>("/chat");
}

app.UseEndpoints(OnEndpointConfigure);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-15
    • 2018-12-07
    • 2019-11-28
    • 1970-01-01
    • 2017-09-14
    • 2019-06-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多