简体   繁体   English

404:signalr / hub用于signalR聊天应用程序

[英]404:signalr/hubs for signalR chat application

I am trying to create a chat application using signalR using VS2012 web in a website. 我正在尝试在网站上使用VS2012 Web使用signalR创建聊天应用程序。 But its showing me error like this: 但是它向我显示了这样的错误:

Failed to load resource: the server responded with a status of 404 (Not Found)   
http://localhost:50780/WebApplication1/WebApplication1/signalr/hubs
Uncaught TypeError: Cannot read property 'client' of undefined

I have added RouteTable.Routes.MapHubs(); 我添加了RouteTable.Routes.MapHubs(); to Global.asax But why should its showing me this error when its opening for other's system. 到Global.asax,但是为什么要在为其他系统打开程序时向我显示此错误。

On the page where you're including signalr/hubs: 在包含信号器/集线器的页面上:

Change your script tag to look like this: 更改脚本标签,使其看起来像这样:

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

@drch's answer is also correct (if you're making that mistake) but the more common issue I see is people just doing "signalr/hubs" in their script tag and then the hubs url is then incorrect (in some circumstances). @drch的答案也是正确的(如果您犯了这个错误),但是我看到的更常见的问题是,人们只是在其脚本标记中执行“ signalr / hubs”,然后集线器url不正确(在某些情况下)。

Ultimately the hubs url resides off of the SignalR endpoint so doing a "~/signalr/hubs" makes the path app relative which should ensure that it retrieves the hubs.js from the correct url. 最终,集线器URL驻留在SignalR端点之外,因此执行“〜/ signalr / hubs”使路径应用程序相对,应确保其从正确的URL中检索到hubs.js。

I know, that I'm late, but for smbd who will finding answers: I've resolved the problem by registrate .Net frame work to IIS. 我知道,我来晚了,但是对于smbd谁会找到答案:我已经通过将.Net框架注册到IIS解决了问题。 Do next steps into console (Win+R): 在控制台(Win + R)中进行下一步:

cd %windir%\Microsoft.NET\Framework\v4.0.30319
aspnet_regiis.exe –i

Source 资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM