Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IIS 7.5下的信号器移动形状演示中未定义客户端属性?_Javascript_Asp.net_Iis_Signalr - Fatal编程技术网

Javascript IIS 7.5下的信号器移动形状演示中未定义客户端属性?

Javascript IIS 7.5下的信号器移动形状演示中未定义客户端属性?,javascript,asp.net,iis,signalr,Javascript,Asp.net,Iis,Signalr,我在IIS 7.5上使用信号器演示移动形状时遇到问题。它适用于我在IIS express和Visual Studio 2013下的开发PC 我目前正在将Move.html文件和/脚本从项目复制到IIS 7.5 PC上的wwwroot目录 当我从http://localhost/Move.html在IIS PC上加载Move.html时,javascript中出现以下错误: 未捕获的TypeError:无法读取未定义的属性“client” 这是我上一行var moveShapeHub=$.conn

我在IIS 7.5上使用信号器演示移动形状时遇到问题。它适用于我在IIS express和Visual Studio 2013下的开发PC

我目前正在将Move.html文件和/脚本从项目复制到IIS 7.5 PC上的wwwroot目录

当我从
http://localhost/Move.html
在IIS PC上加载Move.html时,javascript中出现以下错误:

未捕获的TypeError:无法读取未定义的属性“client”

这是我上一行
var moveShapeHub=$.connection.moveShapeHub,
返回未定义的moveShapeHub的结果

Move.html:

<!DOCTYPE html>
<html>
<head>
    <title>SignalR MoveShape Demo</title>
    <style>
        #shape {
            width: 100px;
            height: 100px;
            background-color: #FF0000;
        }
    </style>
</head>
<body>
    <script src="Scripts/jquery-1.10.2.min.js"></script>
    <script src="Scripts/jquery-ui-1.10.3.min.js"></script>
    <script src="Scripts/jquery.signalR-2.1.2.min.js"></script>
    <script src="/signalr/hubs"></script>
    <script>
        $(function () {
            var moveShapeHub = $.connection.moveShapeHub,
                $shape = $("#shape"),
                // Send a maximum of 10 messages per second
                // (mouse movements trigger a lot of messages)
                messageFrequency = 10,
                // Determine how often to send messages in
                // time to abide by the messageFrequency
                updateRate = 1000 / messageFrequency,
                shapeModel = {
                    left: 0,
                    top: 0
                },
                moved = false;
            moveShapeHub.client.updateShape = function (model) {
                shapeModel = model;
                // Gradually move the shape towards the new location (interpolate)
                // The updateRate is used as the duration because by the time
                // we get to the next location we want to be at the "last" location
                // We also clear the animation queue so that we start a new
                // animation and don't lag behind.
                $shape.animate(shapeModel, { duration: updateRate, queue: false });
            };
            $.connection.hub.start().done(function () {
                $shape.draggable({
                    drag: function () {
                        shapeModel = $shape.offset();
                        moved = true;
                    }
                });
                // Start the client side server update interval
                setInterval(updateServerModel, updateRate);
            });
            function updateServerModel() {
                // Only update server if we have a new movement
                if (moved) {
                    moveShapeHub.server.updateModel(shapeModel);
                    moved = false;
                }
            }
        });
    </script>

    <div id="shape" />
</body>
</html>

一旦启动站点,您是否可以检查您的集线器代理是否正在为/Signalr/hubs加载。只需点击你的URL http://localhost/SignalR/hubs。你应该会看到SignalR生成的代理(除非你在Global.asax中关闭了它,因为你可以在IISExpress中点击它,所以它看起来不像)

如果您可以打开集线器代理,那么只需在HTML中更改以下内容,从

    <script src="/signalr/hubs"></script>

                    to

    <script src="http:/localhost/signalr/hubs"></script>
您可以了解更多关于信号器的信息-关于信号器的一切都是非常好的资源

更新:
您说当在visual studio和IIS中运行时,Move.html工作正常。作为Move.html的一部分,visual studio解决方案或项目中还有什么其他内容?您有用于中心的C#代码,部署了吗?使用/signal/hubs表明Move.html和中心是同一项目的一部分,但在原始查询中您您刚刚移动了Move.html。您必须发布整个项目,并将发布的版本移动到wwwroot文件夹。对于发布步骤,请查看

您是否可以发布中心代码?我已经添加了中心代码和启动代码。此代码直接来自演示,在运行IIS express的开发PC上运行良好。我无法获取它在部署PC上的IIS 7.5下工作。一旦启动站点,您是否可以检查您的集线器代理是否正在为/Signalr/hubs加载?我应该检查什么以查看/Signalr/hubs是否已启动?使用Chrome developer工具,我可以在网络选项卡中看到/Signalr/hubs的状态为“200 OK”。如果我在第20行停止,则在源选项卡下
var moveShapeHub=$.connection.moveShapeHub,
我看到
$.connection.moveShapeHub
未定义,因此可能未加载。我如何加载它?我没有一个Global.asax文件。我看到了创建不同的代理(对于另一个Signer web应用,我尝试了并在加载该页面后获得net::Err\u connection\u Reset错误).因此,对于这个示例,没有信号器代理,没有global.asax,在VS 2013下运行时效果很好,但无法部署…您发送的链接是基本信号器链接,我从中获得了我尝试运行的示例,有没有指向我可以在IIS上成功部署它的更多信息的指针?
using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(MoveShapeDemo.Startup))]
namespace MoveShapeDemo
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // Any connection or hub wire up and configuration should go here
            app.MapSignalR();
        }
    }
}
    <script src="/signalr/hubs"></script>

                    to

    <script src="http:/localhost/signalr/hubs"></script>