9

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

4

3 回答 3

18

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

我希望这有帮助

于 2012-02-16T19:22:45.580 回答
3

我在尝试实现基本的持久连接示例时遇到了完全相同的错误,我花了很长时间才意识到这是由于 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 有关。无论如何,这是我的问题的解决方案。

于 2012-04-05T21:34:18.343 回答
0

有两个步骤:
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-10-15T09:13:53.467 回答