SignalR" signalr /集线器"让404错误 [英] SignalR "signalr/hubs" giving 404 error
问题描述
我在我的项目中使用SignalR(https://github.com/SignalR/SignalR)。从这里<一个href=\"https://github.com/SignalR/SignalR/wiki/QuickStart-Hubs\">https://github.com/SignalR/SignalR/wiki/QuickStart-Hubs我的想法得到了如何使用集线器。但signalr /枢纽的剧本是给404错误。这里是成为查看源代码的网址:的http://本地主机:50378 / signalr /集线器给予404错误
下面是我的code:
枢纽:
公共类测试:集线器
{
公共无效启动()
{
Caller.guid = Guid.NewGuid();
} 公共无效TestMethod的()
{
Clients.show(测试,Caller.guid);
}
}
ASPX:
&LT; HTML的xmlns =http://www.w3.org/1999/xhtml&GT;
&LT;头=服务器&GT;
&LT;标题&GT;标题&LT; /标题&GT;
&LT; SCRIPT SRC =../脚本/ jQuery的-1.6.4.min.js类型=文/ JavaScript的&GT;&LT; / SCRIPT&GT;
&LT; SCRIPT SRC =../脚本/ jquery.signalR.js类型=文/ JavaScript的&GT;&LT; / SCRIPT&GT;
&所述; SCRIPT SRC =&下;%= RESOLVEURL(〜/ signalr /集线器)%&gt;中类型=文/ JavaScript的&GT;&LT; / SCRIPT&GT;
&LT;脚本类型=文/ JavaScript的&GT; $(文件)。就绪(函数(){
VAR测试= $ .connection.test;
$(#为btnTest)。点击(函数(){
test.testMethod();
});
test.show =功能(文字,GUID){
如果(GUID!= test.guid)//通知所有客户端,除了主叫
警报(文本);
};
$ .connection.hub.start(函数(){test.start();});
}); &LT; / SCRIPT&GT;
&LT; /头&GT;
&LT;身体GT;
&LT;表ID =的HtmlForm=服务器&GT;
&LT; DIV&GT; &LT; / DIV&GT;
&LT; /表及GT;
&LT; /身体GT;
&LT; / HTML&GT;
Web.config文件:
&LT; system.webServer&GT;
&LT;验证validateIntegratedModeConfiguration =FALSE/&GT;
&LT;模块runAllManagedModulesForAllRequests =真正的&GT;
....
这可能是因为你还没有加入 SignalR.AspNet.dll
的参考。如果我没有记错它是负责添加路由 / signalr /集线器
。
I am using SignalR(https://github.com/SignalR/SignalR) in my project. From here https://github.com/SignalR/SignalR/wiki/QuickStart-Hubs I got the idea how to use Hubs. But the "signalr/hubs" script is giving 404 error. Here is the url which becomes in View Source: http://localhost:50378/signalr/hubs giving 404 error
Here is my code: Hub:
public class Test:Hub
{
public void Start()
{
Caller.guid = Guid.NewGuid();
}
public void TestMethod()
{
Clients.show("test", Caller.guid);
}
}
ASPX:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Title</title>
<script src="../Scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="../Scripts/jquery.signalR.js" type="text/javascript"></script>
<script src="<%= ResolveUrl("~/signalr/hubs") %>" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
var test = $.connection.test;
$("#btnTest").click(function () {
test.testMethod();
});
test.show = function (text, guid) {
if (guid != test.guid) //notify all clients except the caller
alert(text);
};
$.connection.hub.start(function () { test.start(); });
});
</script>
</head>
<body>
<form id="HtmlForm" runat="server">
<div>
</div>
</form>
</body>
</html>
Web.config:
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
....
It could be that you haven't added a reference to SignalR.AspNet.dll
. If I recall correctly it's responsible for adding the route to /signalr/hubs
.
这篇关于SignalR&QUOT; signalr /集线器&QUOT;让404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!