【发布时间】:2013-10-15 17:34:43
【问题描述】:
我在使用最基本的示例 https://github.com/SignalR/SignalR/wiki/QuickStart-Persistent-Connections 时遇到了问题。我得到“404 on echo/negotiate”
【问题讨论】:
标签: signalr
我在使用最基本的示例 https://github.com/SignalR/SignalR/wiki/QuickStart-Persistent-Connections 时遇到了问题。我得到“404 on echo/negotiate”
【问题讨论】:
标签: signalr
示例已过时。 这是因为默认的 MVC 项目调用 RegisterRoutes(RouteTable.Routes); 您必须将 MapConnection 移动到 RegisterRoutes 内部,在 routes.IgnoreRoute("{resource}.axd/{*pathInfo}"; 之后但在任何其他路线之前。
希望对你有帮助
【讨论】:
我在尝试实现基本的持久连接示例时遇到了完全相同的错误,我花了很长时间才意识到这是由于 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 有关。无论如何,这是我的问题的解决方案。
【讨论】:
有两个步骤:
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(){}
祝你好运!
【讨论】: