相关疑难解决方法(0)

signalR:/ signalr/hubs未生成

我可以让本教程在新项目中工作,但不能在我现有的项目中工作.

我的项目是一个ASP.Net MVC 4 Web应用程序,在web.config文件中具有以下属性:

<appSettings>
  <add key="webpages:Enabled" value="true"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)

这是因为我的应用程序是单页面应用程序,它在客户端使用AngularJS.我的应用程序中唯一的页面是index.cshtml,我已经为signalR添加了相关的代码:

 <!-- signalR chat -->
<script src="~/Scripts/jquery.signalR-1.0.0.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="/signalr/hubs"></script>
<!--Add script to update the page and send messages.--> 
<script type="text/javascript">
    $(function () {
        // Declare a proxy to reference the hub. 
        var chat = $.connection.chatHub;
        // Create a function that the hub can call to broadcast messages.
        chat.client.broadcastMessage = function (name, message) {
            // Html encode display name and message. 
            var …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc-4 signalr angularjs single-page-application

23
推荐指数
2
解决办法
3万
查看次数