hello sir i was trying to use push notification and it woirked with signalr1.x.x with asp.net , but when i tried with mvc .net 4.5 and signalr 2.x.x it is not working could you pls help me
{
ViewBag.Title = "chat";
}
<html lang="en">
<head>
<meta charset="utf-8" />
<script src="~/Scripts/jquery.signalR-2.1.1.js" ></script>
<script src="/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
var proxy = $.connection.myHub;
proxy.client.receiveNotification = function (message) {
$('#listmsg').append('<li>' + message + '</li>');
};
$('#sendmsg').click(function () {
proxy.server.sendNotifications($('#txtmsg').val());
});
$.connection.hub.start();
});
</script>
</head>
<body>
<input type="text" id="txtmsg" />
<input type="button" id="sendmsg" value="button"/>
<ul id="listmsg"></ul>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;
namespace MvcApplication9.Hubs
{
public class MyHub:Hub
{
public void SendNotifications(string message)
{
Clients.All.receiveNotification(message);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(MvcApplication9.Startup))]
namespace MvcApplication9
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
public ActionResult chat()
{
return View();
}