Angular C# WebAPI SignalR:- Error loading hubs. En

2019-07-25 13:24发布

1条回答
We Are One
2楼-- · 2019-07-25 13:56

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");

I updated it as

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");

Now one problem is solved.

查看更多
登录 后发表回答