子域上的SignalR协商404 [英] SignalR Negotiate 404 on Subdomain

查看:85
本文介绍了子域上的SignalR协商404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个小型MVC SignalR应用程序,该应用程序在子域下的服务器上运行时遇到问题: http://chat.mydomain.com ,它映射到名为/chat的文件夹.

I've created a small MVC SignalR app which I'm having trouble running on my server under a subdomain: http://chat.mydomain.com, which maps to a folder called /chat.

我还使用SignalR Client制作了一个控制台程序,该程序可以连接并且完美地运行,非常奇怪.

I've also made a console program using SignalR Client which connects and works perfectly, strangely enough.

MVC应用程序中的错误是来自 http:的404://chat.mydomain.com/chat/signalr/negotiate?clientProtocol = [...] .我知道为什么会发生这种情况,但不知道如何解决.在我生成的中心文件中,行

The error from the MVC app is a 404 from http://chat.mydomain.com/chat/signalr/negotiate?clientProtocol=[...]. I can see why this is happening but have no idea how to fix it. In my generated hubs file, the line

signalR.hub = $.hubConnection("/chat/signalr", { useDefaultPath: false });

从技术上讲是正确的,但应阅读 $.hubConnection("/signalr",{useDefaultPath:false});

is technically correct, but should read $.hubConnection("/signalr", { useDefaultPath: false });

关于如何更改此设置的任何想法?还是我应该只使用原始连接API.

Any ideas on how to alter this? Or should I just use the raw connection API.

为什么它也可以从控制台应用程序正常工作?

Also why does it work properly from the console app?

提前谢谢.

推荐答案

您可以继续使用生成的中心文件.您只需在启动SignalR连接之前修改hubConnection的url(存储在 $.connection.hub.url 中).

You can continue to use the generated hubs file. You just need to modify the hubConnection's url (which stored at $.connection.hub.url) before you start your SignalR connection.

// This is initially set to "/chat/signalr" as specified in the hubs file
$.connection.hub.url = "/signalr";
$.connection.hub.start()...

这篇关于子域上的SignalR协商404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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