Issue whille calling SignalR hub from WebAPI controller
<p>I cannot figure out what is going wrong out here.</p>

<p>I have created new project from the ASP.NET MVC WebAPI template.Added a new SignalR Hub to the project called MyHub. Added an HTML page that on load, connects to Hub and sends a message. HTML page has a button that when clicked will fire an ajax call to the APIController's post method. In the APIController's post method, I want to broadcast a message to all the connected clients. I cannot get this to work.</p>

<h2>ChatHub.cs</h2>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;

namespace SignalRServerAPIHub
{
    [HubName("chatHub")]
    public class ChatHub : Hub
    {
        public void Send(string message)
        {
            Clients.All.broadcastMessage(message);
        }
    }
}
</code></pre>

<h2>Index.html</h2>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;SignalR Simple Chat&lt;/title&gt;
    &lt;style type="text/css"&gt;
        .container {
            background-color: #99CCFF;
            border: thick solid #808080;
            padding: 20px;
            margin: 20px;
        }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div class="container"&gt;
        &lt;input type="text" id="message" /&gt;
        &lt;input type="button" id="sendmessage" value="Send" /&gt;
        &lt;input type="hidden" id="displayname" /&gt;
        &lt;ul id="discussion"&gt;&lt;/ul&gt;
    &lt;/div&gt;
    &lt;!--Script references. --&gt;
    &lt;!--Reference the jQuery library. --&gt;
    &lt;script src="Scripts/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
    &lt;!--Reference the SignalR library. --&gt;
    &lt;script src="Scripts/jquery.signalR-2.2.0.min.js"&gt;&lt;/script&gt;
    &lt;!--Reference the autogenerated SignalR hub script. --&gt;
    &lt;script src="signalr/hubs"&gt;&lt;/script&gt;
    &lt;!--Add script to update the page and send messages.--&gt;
    &lt;script type="text/javascript"&gt;
        $(function () {
            // Declare a proxy to reference the hub.
            var chat = $.connection.chatHub;
            // Create a function that the hub can call to broadcast messages.
        chat.client.broadcastMessage = function (message) {
            // Html encode display message.
                var encodedMsg = $('&lt;div /&gt;').text(message).html();
            // Add the message to the page.
            $('#discussion').append('&lt;li&gt;&lt;strong&gt;' + &lt;/strong&gt;:&amp;nbsp;&amp;nbsp;' + encodedMsg + '&lt;/li&gt;');
        };
        // Set initial focus to message input box.
        $('#message').focus();
        // Start the connection.
        $.connection.hub.start()//.done(function () {
            $('#sendmessage').click(function () {
                $.ajax({
                    url: "api/Test/PostSampleMessage",
                    data: { 'Message': $('#message').val() },
                    type: "POST"
                });
                // Clear text box and reset focus for next comment.
                $('#message').val('').focus();
            });
        //});
    });
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Whenever the connected hub receives a new message, a new item is added to the unordered list. There is a button that makes an Ajax call into the TestController post method.</p>

<h2>API Controller</h2>

<pre><code>public class TestController : ApiController
{
    [HttpPost]
    public void PostSampleMessage([FromBody] FormData data)
    {
        var hubContext = GlobalHost.ConnectionManager.GetHubContext&lt;MyHub&gt;();
        hubContext.Clients.All.send(data.Message);
    }
}
</code></pre>

<h2>FormData Class</h2>

<pre><code>public class FormData
    {
        public string Message { get; set; }
    }
</code></pre>

<h2>Startup.cs</h2>

<pre><code>using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;
using Microsoft.Owin.Cors;
using Microsoft.AspNet.SignalR;

[assembly: OwinStartup(typeof(SignalRServerAPIHub.Startup))]

namespace SignalRServerAPIHub
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.Map("/signalr", map =&gt;
            {
                map.UseCors(CorsOptions.AllowAll);
                var hubConfiguration = new HubConfiguration { };
                map.RunSignalR(hubConfiguration);
            });
        }
    }
}
</code></pre>

<p>Looks like the Hub call is not working. I am not getting any error generated from this, but not getting the message back for the clients.</p>

<p>Any help is appreciated.</p>