「HotTowel」シングルページアプリテンプレートを使用していますが、SignalRを機能させることができません。次のエラーが発生します。
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8184/signalr/hubs
標準のMVC4シングルページアプリを使用して、非常にシンプルなハブを配置した一種の定型文を作成しました(ユーザーのオンラインカウンター)。すべてが正常に機能していました。
「HotTowel」に切り替えた後、動作を停止しました。John Papaに確認したところ、ルーティングを妨げるいくつかの問題について修正が行われることを知っていたため、Durandal側で確認するよう提案されました。
main.js:
require.config({
paths: {
"text": "durandal/amd/text",
"signr": "../scripts/jquery.signalR-1.0.1.min"
}
});
define(['durandal/app', 'durandal/viewLocator', 'durandal/system', 'durandal/plugins/router', 'services/logger', "signr"],
function (app, viewLocator, system, router, logger, sigr) {
// Enable debug message to show in the console
system.debug(true);
app.start().then(function () {
toastr.options.positionClass = 'toast-bottom-right';
toastr.options.backgroundpositionClass = 'toast-bottom-right';
router.handleInvalidRoute = function (route, params) {
logger.logError('No Route Found', route, 'main', true);
};
// When finding a viewmodel module, replace the viewmodel string
// with view to find it partner view.
router.useConvention();
viewLocator.useConvention();
// Adapt to touch devices
app.adaptToDevice();
//Show the app by setting the root view model for our application.
app.setRoot('viewmodels/shell', 'entrance');
});
});
Global.asax.cs:
protected void Application_Start()
{
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
// Register the default hubs route: ~/signalr/hubs
RouteTable.Routes.MapHubs();
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
HotTowel \ index.cshtml:
<body>
<div id="applicationHost">
@Html.Partial("_splash")
</div>
@Scripts.Render("~/scripts/vendor")
@if(HttpContext.Current.IsDebuggingEnabled) {
<script type="text/javascript" src="~/App/durandal/amd/require.js" data-main="@Url.Content("~/App/main")"></script>
} else {
<!-- Remember to run the Durandal optimizer.exe to create the main-built.js -->
<script type="text/javascript" src="~/App/main-built.js"></script>
}
<script type="text/javascript" src="~/signalr/hubs"></script>
@*<script src="~/App/services/hubs.js"></script>*@
</body>
(これはおそらくそれを置く場所ではないことを知っていますが、ここに置くまで、ソースに表示させることはできませんでした)-ちなみに、正しい方法を教えていただければ、感謝します
これをトラブルシューティングするのに役立つ他に何を教えてもらえますか?SignalRなどへのすべての参照があります...別のプロジェクトテンプレートを使用した実用的な例があります...
誰かが私を導くことができますか?
複製するのは簡単なはずです。
- 「HotTowel」テンプレートを使用するだけです
- すべてのSignalR参照を追加します
- 私のコードでテストする
DurandalかRequire.Jsのどちらかがこれを邪魔していると思います。誰かがその日を救うことができますか?:)