Reputation: 9224
I followed the following video on getting signal and webapi running together: Video
However, I'm unable to get it working on my solution. I have an empty api project that has references to many other projects that have the api controllers defined for their functionality.
In one of the other projects, I wanted to add a signalr hub to communicate with the client. So, I added signalR through nuget.
Right off the bat I began getting an OWIN error so I added the following to the app settings
<add key="owin:AutomaticAppStartup" value="false" />
I've added the hubcontext to the controller in question like so:
private readonly Lazy<IHubContext> _hub = new Lazy<IHubContext>(
() => GlobalHost.ConnectionManager.GetHubContext<TaskHub>());
/// <summary>
/// Gets the hub.
/// </summary>
protected IHubContext Hub
{
get { return _hub.Value; }
}
Then in one of the api calls, I added the following code to send a message to the client:
Hub.Clients.All.taskLoaded();
When I started to work on the client, the connection would fail each time. After some investigation I learned that .../signalr/negotiate
is always returning 404
.
There is clearly something I doing wrong. But I can't figure it out.
Upvotes: 0
Views: 898
Reputation: 31610
You seem to not have mapped SignalR. Add MapSignalR()
to your Configuration
method in the Startup
class.
Upvotes: 1