【问题标题】:SignalR 404 when connecting using .Net Client使用 .Net 客户端连接时的 SignalR 404
【发布时间】:2018-11-14 14:45:38
【问题描述】:

连接到 SignalR 核心时,我们需要输入什么 URL。 当我们尝试将 Url 设置为 https://localhost:44308 时,它显示未找到。是的,Web 服务器正在运行。是否需要任何后缀?

        HubConnection connection;
        connection = new HubConnectionBuilder()
            .WithUrl(**Url**)
            .Build();
        await connection.StartAsync();
        bool isClosed = false;
        connection.Closed += async (error) =>
        {
            isClosed = true;
            await Task.Delay(new Random().Next(0, 5) * 1000);
            await connection.StartAsync();
        };
        if (isClosed == false)
        {
            connection.InvokeAsync("NewMessage", "from server", $"{DateTime.Now.ToShortDateString()}").Wait();
        }

【问题讨论】:

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


    【解决方案1】:

    信号核心的变化: https://localhost:44308 应该包含 Hub 后缀,所以正确的 URL 是:

    https://localhost:44308/hub

    这可以在 Startup.cs 中配置

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 2012-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多