相关疑难解决方法(0)

SignalR"signalr/hubs"给出404错误

我在我的项目中使用SignalR(https://github.com/SignalR/SignalR).从这里https://github.com/SignalR/SignalR/wiki/QuickStart-Hubs我明白了如何使用Hubs.但"信号器/集线器"脚本给出了404错误.这是在视图源中的URL:http:// localhost:50378/signalsr/hubs给出404错误

这是我的代码:Hub:

public class Test:Hub
{
    public void Start()
    {
        Caller.guid = Guid.NewGuid();
    }

    public void TestMethod()
    {
        Clients.show("test", Caller.guid);
    }
}
Run Code Online (Sandbox Code Playgroud)

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(); …
Run Code Online (Sandbox Code Playgroud)

c# asp.net signalr

49
推荐指数
5
解决办法
5万
查看次数

标签 统计

asp.net ×1

c# ×1

signalr ×1