Angular C#WebAPI SignalR:-加载集线器时出错.确保您的集线器参考正确 [英] Angular C# WebAPI SignalR:- Error loading hubs. Ensure your hubs reference is correct

查看:68
本文介绍了Angular C#WebAPI SignalR:-加载集线器时出错.确保您的集线器参考正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重复的错误加载中心.确保您的集线器引用正确无误,例如< script src ='/signalr/js'></script>

但是还没有答案.请帮忙.

But no answer yet. Please help.

推荐答案

矿井是一个愚蠢的错误!希望这会在将来对其他人有所帮助.我有AngularJS前端和C#Web API后端.所以我的路由是在Angular中进行的,并且Web API有一个路由来确保angular可以完成所有路由.所以在我的Global.asax文件中,代码如下

Mine was a stupid mistake! Hope this might help others in future. I have AngularJS front end and C# Web API back end. So my routing was in Angular and Web API had a routing to make sure that angular does all the routing. So in my Global.asax file, the code was as follows

string url = Request.Url.LocalPath;
            if (!System.IO.File.Exists(Context.Server.MapPath(url)) && !url.Contains("/api/"))
                Context.RewritePath("/View/app/index.html");

我将其更新为

string url = Request.Url.LocalPath;
            if (!System.IO.File.Exists(Context.Server.MapPath(url)) && !url.Contains("/api/") &&  !url.Contains("/signalr") )
                Context.RewritePath("/View/app/index.html");

现在解决了一个问题.

这篇关于Angular C#WebAPI SignalR:-加载集线器时出错.确保您的集线器参考正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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