【问题标题】:SignalR Persistent connection giving 404 on echo/negotiateSignalR 持久连接在回显/协商时给出 404
【发布时间】:2013-10-15 17:34:43
【问题描述】:

我在使用最基本的示例 https://github.com/SignalR/SignalR/wiki/QuickStart-Persistent-Connections 时遇到了问题。我得到“404 on echo/negotiate”

【问题讨论】:

    标签: signalr


    【解决方案1】:

    示例已过时。 这是因为默认的 MVC 项目调用 RegisterRoutes(RouteTable.Routes); 您必须将 MapConnection 移动到 RegisterRoutes 内部,在 routes.IgnoreRoute("{resource}.axd/{*pathInfo}"; 之后但在任何其他路线之前。

    希望对你有帮助

    【讨论】:

    • 我尝试使用相同的示例实现 SignalR,但遇到了同样的问题。 /echo/negotiate 仍然是 404'ing.. 有人可以帮忙吗?
    • 再次尝试阅读我的解决方案,RegisterRoutes 的顺序很重要
    【解决方案2】:

    我在尝试实现基本的持久连接示例时遇到了完全相同的错误,我花了很长时间才意识到这是由于 Newtonsoft.Json 的版本不匹配,这里描述的问题和解决方案:

    https://github.com/SignalR/SignalR/issues/195

    即添加如下部分:

    <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.0.8.0" />
    </dependentAssembly>
    

    到您的 web.config。

    不知道为什么我缺少该部分,因为据我了解它应该由 nuget 自动添加,可能与 Visual Studio 11 beta 有关。无论如何,这是我的问题的解决方案。

    【讨论】:

    • 谢谢你,我花了一段时间才注意到这一点,如果我能给你一千分我会
    • 疯了,我也遇到了同样的问题。在本地我的应用程序很好,但在调用信号器时得到 404。我将此添加到服务器上的 web.config 中,然后噗:工作。
    【解决方案3】:

    有两个步骤:
    1.在web.config添加或编辑规则json

     <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json"
     publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
     <bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.0.8.0" />
     </dependentAssembly>
    


    2.在Global.asax新增:

    RouteTable.Routes.MapConnection<ChatConnection>("negotiate", "/chat");
    


    在方法protected void Application_Start(){}

    祝你好运!

    【讨论】:

      猜你喜欢
      • 2013-11-23
      • 2016-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多