Using SignalR in a Website Project

微笑、不失礼 提交于 2019-12-06 05:26:21

问题


I'm trying a very simple demo of SignalR but getting the infamous "undefined" error on the following line in my javascript:

var myHub = $.connection.myHub;

MyHub.cs is as follows:

public class MyHub : Hub
{
    ...
}

Most of the examples I've seen so far are MVC or web application projects. With those, MyHub.cs would be placed in the App_Code folder. However, our project is a website project and we can't change it to a web application.

What can I do to make it work?


回答1:


It turned out that I missed the following in web.config:

<modules runAllManagedModulesForAllRequests="true">

And yes, you can absolutely use SignalR in a website project.



来源:https://stackoverflow.com/questions/11130296/using-signalr-in-a-website-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!