在一个网站项目使用SignalR [英] Using SignalR in a Website Project

查看:98
本文介绍了在一个网站项目使用SignalR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想SignalR一个非常简单的演示,但得到了臭名昭著的不确定的错误在下一行在我的javascript:

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如下:

MyHub.cs is as follows:

public class MyHub : Hub
{
    ...
}

大多数迄今为止我见过的例子是MVC或Web应用程序项目。与那些,MyHub.cs将被放置在APP_ code夹。然而,我们的项目是一个网站项目,我们不能将其更改为一个Web应用程序。

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?

推荐答案

原来,我错过了在web.config中以下内容:

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

<modules runAllManagedModulesForAllRequests="true">

是的,你可以绝对网站项目中使用SignalR。

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

这篇关于在一个网站项目使用SignalR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆