Last post Apr 07, 2016 08:17 AM by Fei Han - MSFT
Mar 31, 2016 03:23 PM|Scout7|LINK
Hi all, I am going around in circles here and cannot find any tutorials or examples that meet my needs. I have an existing web application written in c# based on MVC, knockout.js and a RESTful Web Api that handles all of the back end service. I need to be
able to include SignalR to update the UI from the Web Api in real time for a booking system. Can anyone point me to any examples of such a set up? Both the Web App UI and Web Api are on separate URL's but do reside on the same server. All the examples and
tutorials I can find only seem to include both the Web App and Web Api inside the same single project whereas I have 2 separate projects. I posted a similar question here last week but did not get much in the way of a response so any help greatly appreciated.
Apr 01, 2016 07:21 AM|Fei Han - MSFT|LINK
You could try to use the following code to broadcast message to clients from controller action.
var hubContext = GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
Besides, it could be difficult for searching some samples that could meet all of your requirements, you had better to learn the basic usage of ASP.NET SignalR.
Apr 01, 2016 01:35 PM|Scout7|LINK
Thank you for your reply, I am just missing that light-bulb moment! As a very basic setup if I could find a very basic cross domain web app / web api example where the web api pushes in real time would be great. I am going around in circles. Here is an example
of where I have got to so far;
I have created a solution called 'SignalR.Solution' that contains to 2 projects called 'SignalR.Api' (which is an MVC API project with its own URL and app pool in IIS) and 'SignalR.Web' (which is an MVC web App project with its own URL and app pool in IIS).
I have installed the signalr packages in both projects. I have also installed the owin package in the api.
I have created an OWIn startup class in my api project.
From my client I am trying to access the api signalr as follows <script src="http://local.signalr.api.com/signalr/hubs"></script>
and a function with this '.connection.hub.url = 'http://local.signalr.api.com/signalr';'
As a basic test I try to run this and get the following errors;
I know there is a lioghtbulb moment that I am missing here but I am getting very frustrated so if anybody can help save my sanity I would greatly appreciate it!
Apr 07, 2016 08:17 AM|Fei Han - MSFT|LINK
Do you have OWIN Startup Class? You could add a plain Class called Startup instead, and change the contents of the new Startup class to the following.
public class Startup
public void Configuration(IAppBuilder app)
// Any connection or hub wire up and configuration should go here
Besides, this link discussed a similar issue, you could refer to it.