Requirejs Durandal/Require.JS-未找到信号器/集线器参考
我正在使用“热毛巾”单页应用程序模板,但我无法让信号器工作。我得到以下错误:Requirejs Durandal/Require.JS-未找到信号器/集线器参考,requirejs,signalr,singlepage,durandal,Requirejs,Signalr,Singlepage,Durandal,我正在使用“热毛巾”单页应用程序模板,但我无法让信号器工作。我得到以下错误: Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8184/signalr/hubs 我有一个使用标准MVC4单页应用程序的样板,有一个非常简单的中心(用户在线计数器)。一切正常 我换成“热毛巾”后,它就停止工作了。我和约翰·帕帕商量过了,他给了我一个建议,让我在杜兰达尔那边进
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8184/signalr/hubs
我有一个使用标准MVC4单页应用程序的样板,有一个非常简单的中心(用户在线计数器)。一切正常
我换成“热毛巾”后,它就停止工作了。我和约翰·帕帕商量过了,他给了我一个建议,让我在杜兰达尔那边进行检查,因为他提到他知道一些干扰某些路线的问题即将得到解决
main.js:
require.config({
路径:{
“文本”:“durandal/amd/text”,
“signr”:“./scripts/jquery.signar-1.0.1.min”
}
});
定义(['durandal/app'、'durandal/viewLocator'、'durandal/system'、'durandal/plugins/router'、'services/logger'、“signr”],
功能(应用程序、视图定位器、系统、路由器、记录器、sigr){
//启用调试消息以显示在控制台中
系统调试(true);
app.start().then(函数(){
toastr.options.positionClass='toast bottom right';
toastr.options.backgroundpositionClass='toast bottom right';
router.handleInvalidRoute=函数(路由,参数){
logger.logError('未找到路由',路由'main',true);
};
//查找viewmodel模块时,请替换viewmodel字符串
//以查看“查找it合作伙伴”视图。
router.useConvention();
viewLocator.useConvention();
//适应触摸设备
app.adaptodevice();
//通过设置应用程序的根视图模型来显示应用程序。
app.setRoot('viewmodels/shell','entry');
});
});
Global.asax.cs:
受保护的无效应用程序\u Start()
{
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
//注册默认集线器路由:~/signalr/hubs
RouteTable.Routes.MapHubs();
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
hottower\index.cshtml:
@Html.Partial(“\u splash”)
@Scripts.Render(“~/Scripts/vendor”)
@if(HttpContext.Current.IsDebuggingEnabled){
}否则{
}
@**@
(我知道这可能不是放它的地方,但在我把它放在这里之前,我无法让它出现在我的资料来源上)-顺便说一句,如果你能告诉我正确的方法,我将不胜感激
我还能告诉你什么来帮助我解决这个问题?我有所有关于信号员的资料等等。。。我有一个使用另一个项目模板的工作示例
有人能指引我吗
它应该很容易复制:
我认为Durandal或Require.Js都会妨碍这一点。有人能拯救这一天吗?:) 问题是信号机需要先登记其路线。HotTower模板试图通过使用带有WebActivator的PreApplicationStartMethod“成为第一” 有几种方法可以解决这个问题。。我们有可用的WebActivator,因此您可以在App_Start中创建一个新类(比如SignalRConfig.cs),如下所示:
[assembly: WebActivator.PreApplicationStartMethod(
typeof(SignalRConfig), "RegisterRoutes", Order = 1)]
public static class SignalRConfig
{
public static void RegisterRoutes()
{
RouteTable.Routes.MapHubs();
}
}
这将在加热炉前登记信号员的路线。删除对global.asax中MapHubs的调用,因为这将为您处理
或者,打开HotTowerRouteConfig.cs并删除/注释掉此属性:
[assembly: WebActivator.PreApplicationStartMethod(
typeof(Empire.Web.App_Start.HotTowelRouteConfig), "RegisterHotTowelPreStart", Order = 2)]
然后进入global.asax,在调用RouteTable.Routes.MapHubs()之后,添加:
在这之后,他们应该玩得很好。嗨,布兰登!太棒了!:)非常感谢你!我还不太熟悉WebActivator的概念。是的,我们使用WebActivator的原因是为了帮助避免在您身上搞乱全局asax。安装hot Tobble后,您可以删除web activator代码并添加自己的路由。另一种选择是添加全局asax代码,但这意味着如果将HotTower用作NuGet包,它将与现有的global.asax冲突。换句话说,这两种方式都不完美。无论如何-最好的方法是在app_start/global.asax中添加您的路由,然后删除或移动web activator代码。
HotTowelRouteConfig.RegisterHotTowelPreStart();