title: How to call multiple hub method from SignalR
body: <p>I am using SignalR and MVC.</p>
  
  <p>I have developed an admin page where I can send notifications. There is a menu with an icon to display the unread notification. </p>
  
  <p>If I click on the count a notification panel will display with the latest 5 notifications. </p>
  
  <p>There is also a "View All" link which opens a new page to show all the notifications. If admin add new notification, I want to update the notification count as well as the view "All notification" page. </p>
  
  <p>How can I call both the hub method on admin send button? I am expecting to see the newly added Notification in the <code>ViewAllNotification</code> page without refreshing. Expecting SignalR to push the data. </p>
  
  <p>I have followed <a href="http://venkatbaggu.com/signalr-database-update-notifications-asp-net-mvc-usiing-sql-dependency/" rel="nofollow">http://venkatbaggu.com/signalr-database-update-notifications-asp-net-mvc-usiing-sql-dependency/</a> for my development. </p>
  
  <p>Here i am not using sql dependency. On Send button(Admin screen) i am calling the hub methods to push notification</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
          $(function () {
              $.connection.hub.logging = true;
              var proxy = $.connection.broadcastMessage;
  
              $.connection.hub.start().done(function () {
                  $('#button1').click(function () {
                      proxy.server.broadcastNotifications($("#Message").val());
                      proxy.server.sendMessages();
                  });
              });
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>This is the Hub method.</p>
  
  <pre><code>    public class BroadcastMessage: Hub
          {
          public void BroadcastNotifications(string message)
          {         
              Utility.AddNotification(message);
  
              int UnreadCount = Utility.getUnreadMessageCount();
  
              IHubContext context = GlobalHost.ConnectionManager.GetHubContext&lt;BroadcastMessage&gt;();
              context.Clients.All.receiveNotification(message, UnreadCount);
          }
  
          public static void SendMessages()
          {
              IHubContext context = GlobalHost.ConnectionManager.GetHubContext&lt;BroadcastMessage&gt;();
              context.Clients.All.updateMessages();
          }
      }
  </code></pre>
  
  <p>I have tried the above jQuery and signal r to call method one by one. But this doesn't work. It calls the first method and the second one didn't get invoked.</p>
  
  <pre><code>@model IEnumerable&lt;Notification&gt;
  @{
      Layout = "~/Views/Shared/_Layout.cshtml";
  }
  &lt;h2&gt;ViewAllNotifications&lt;/h2&gt;
  &lt;div class="container"&gt;
  &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.NotificationID)&lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Message)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.CreatedBy)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.CreatedDate)
          &lt;/th&gt;
  
      &lt;/tr&gt;
  
  @foreach (var item in Model) {
      &lt;tr&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.NotificationID)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.Message)
          &lt;/td&gt;
          &lt;th&gt;
              @Html.DisplayFor(modelItem =&gt; item.CreatedBy)
          &lt;/th&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.CreatedDate)
          &lt;/td&gt;
  
      &lt;/tr&gt;
  }
  
  &lt;/table&gt;
  
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
  
          $(function () {
              debugger;
              $.connection.hub.logging = true;
              var proxy = $.connection.broadcastMessage;
  
              proxy .client.updateMessages = function () {
                  getAllMessages()
              };
              $.connection.hub.start().done(function () {
                  alert("connection started")
  
                  getAllMessages();
              }).fail(function (e) {
                  alert(e);
              });
              function getAllMessages() {
                  var tbl = $('#messagesTable');
  
                  $.ajax({
                      url: '/Notifications/GetMessages',
                      cache: false,
                      contentType: 'application/html ; charset:utf-8',
                      type: 'GET',
                      dataType: 'html'
                  }).success(function (result) {
                      tbl.empty().append(result);
                  }).error(function () {
  
                  });
              }
  
          });
  &lt;/script&gt;
  </code></pre>
  
  <p>Above is the partial view.And i was referring to <a href="http://venkatbaggu.com/signalr-database-update-notifications-asp-net-mvc-usiing-sql-dependency/" rel="nofollow">http://venkatbaggu.com/signalr-database-update-notifications-asp-net-mvc-usiing-sql-dependency/</a> 
  My req is to push notification to this page whenever admin send notifications.</p>