C# 信号器:加载集线器时出错。404找不到
我正在使用angular 5应用程序,我正在尝试实现SignalR。我得到了两个错误,我可以想象它们是一样的。首先是: 加载资源失败:服务器响应状态为404(未找到) 第二个是: 错误:信号器:加载集线器时出错。确保您的集线器参考是正确的,例如 也就是说,我一直在研究这一点,并看到了一些选项,其中大部分都引用了旧版本的siganalR 我已经在这个基础上添加了一个中心C# 信号器:加载集线器时出错。404找不到,c#,signalr,C#,Signalr,我正在使用angular 5应用程序,我正在尝试实现SignalR。我得到了两个错误,我可以想象它们是一样的。首先是: 加载资源失败:服务器响应状态为404(未找到) 第二个是: 错误:信号器:加载集线器时出错。确保您的集线器参考是正确的,例如 也就是说,我一直在研究这一点,并看到了一些选项,其中大部分都引用了旧版本的siganalR 我已经在这个基础上添加了一个中心 [HubName("EventContractHub")] public class EventContractHub : Hu
[HubName("EventContractHub")]
public class EventContractHub : Hub, IClientHub
{
public void SendId(int id)
{
Clients.All.Send(id);
}
}
使用一个看起来像
[assembly:OwinStartUp(typeof(blah.Startup))]
namespace blah
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
// Other configuration here
app.MapSignalR();
}
}
}
我的\u Layout.cshtml
有一个如下引用:
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.signalR-2.2.3.min.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="~/signalr/hubs"></script>
检查链接教程中的注释 重要的 将信号器和其他脚本库添加到Visual Studio项目时,包管理器可能会安装比本主题中显示的版本更新的信号器脚本文件版本。确保代码中的脚本引用与项目中安装的脚本库版本匹配 因此,首先确保引用了正确的版本 考虑将与信号器相关的引用添加到捆绑包中
public class BundleConfig {
public static void RegisterBundles(BundleCollection bundles) {
//... other bundles
bundles.Add(new ScriptBundle("~/bundles/jquery")
.Include("~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/signalr").Include(
"~/Scripts/jquery.signalr-*", //the * wildcard will get script regardless of version
"~/signalr/hubs"));
//Enable minification
BundleTable.EnableOptimizations = true;
}
}
//...in start up
BundleConfig.RegisterBundles(BundleTable.Bundles);
在我看来
<!-- javascript: Placed at the end of the document so the pages load faster -->
@Scripts.Render("~/bundles/jquery", "~/bundles/signalr")
不,没有,我试过
~/signar/hubs
,signar/hubs
,/intellim/signar/hubs
,如果您阅读了同一链接教程中的注释,其他人也有同样的问题。检查以确保您调用的URL路径正确。同时确保您引用的jqueryYou提到有其他API的正确版本。信号员何时就该服务进行登记?它们添加到管道中的顺序也很重要。我在API注册前后都尝试过。我还将添加Api注册。谢谢,我在将jquery更新为2.2.2之后能够找到hubs文件
<!-- javascript: Placed at the end of the document so the pages load faster -->
@Scripts.Render("~/bundles/jquery", "~/bundles/signalr")
public void Configuration(IAppBuilder app) {
//Auth
this.ConfigureAuth(app);
//SignalR
app.MapSignalR();
//...other configuration.
}