Я работаю над проектом в MVC 5 и SignalR, чтобы обновлять в режиме реального времени представления при изменении базы данных SQL Server. Мои взгляды выглядят следующим образом:Reference SignalR и Noty во всех представлениях проекта MVC 5
@model IEnumerable<iCare.Models.HttpPop3>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<div class="row">
<div class="col-md-12">
<div id="httpPop3sTable"></div>
</div>
</div>
@section Scripts{
<script src="/Scripts/jquery.signalR-2.1.2.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="/signalr/hubs"></script>
<script type="text/javascript">
$(function() {
// Declare a proxy to reference the hub.
var notifications = $.connection.tableHub;
//debugger;
// Create a function that the hub can call to broadcast messages.
notifications.client.updateHttpPop3s = function() {
getAllHttpPop3s()
};
// Start the connection.
$.connection.hub.start().done(function() {
alert("connection started")
getAllHttpPop3s();
}).fail(function (e) {
alert(e);
});
});
function getAllHttpPop3s() {
var tbl = $('#httpPop3sTable');
$.ajax({
url: '/httpPop3/GetHttpPop3s',
contentType: 'application/html ; charset:utf-8',
type: 'GET',
dataType: 'html'
}).success(function (result) {
tbl.empty().append(result);
}).error(function() {
});
}
</script>
}
Я хотел бы добавить SignalR Noty ссылку для всех представлений с из положить эти каждый раз. Так я гугл и добавил код Подписок к моему проекту:
BundleConfig.cs
bundles.Add(new ScriptBundle("~/bundles/noty").Include(
"~/Scripts/noty/layouts/",
"~/Scripts/noty/themes/",
"~/Scripts/noty/jquery.noty.js"));
bundles.Add(new ScriptBundle("~/bundles/SignalR").Include(
"~/Scripts/jquery-2.1.1.js",
"~/Scripts/jquery.signalR-2.1.2.js",
"~/Scripts/hubs.js"));
_Layout.cshtml
@Scripts.Render("~/bundles/noty")
@Scripts.Render("~/bundles/signalr")
Но когда я запускаю представление, которое использует SignalR он говорит, что может, Не находите, что макеты хаба и noty не отображаются на странице.
Спасибо