SignalR in SharePoint 2013 – the real-time web is coming!

14 Dec 2012
December 14, 2012

If you never heard of SignalR – it’s a real-time web framework for bi-directional communication between a client and server – in short: your server (here SharePoint) can notify a client that something very important happened. Let’s say you want to have Task List and a Dashboard where you can see how many tasks are open (you can watch this example here by Matt Menezes)– in real-time, without hitting F5 permanently and without having an AJAX function polling the list every second. With SignalR that’s possible and the good thing its very easy, some say its magic! I did a small example for visualizing downloads from my SharePoint farm and IMHO it looks very cool. Things change rapidly, as I wrote this I used Microsoft.AspNet.SignalR 1.0 Alpha 2.


Update 02/05/2013: SignalR has changed a lot  – I will write a blog post because the current approach is to complicated for the current SignalR version. Use at your own risk!

Update 06/05/2013: Open Source Solution available  – I released a Codeplex project for SharePoint+SignalR. Please go to 


SharePoint 2010 makes it tough!

You all know that SharePoint 2010 runs on .NET Framework 3.5 – yepp, its not getting better. Thing is, SignalR needs .NET Framework 4.0 or 4.5. So the easiest solution was to create a second Application Pool, select .NET Framework 4.0/4.5 and host the SignalR application there. I used a WCF Service in that application, SharePoint event receivers can call the WCF Service and voila you are in the 4.0/4.5 domain (if you are lucky without cross domain issues…).

SharePoint 2013 doesn’t make it easier!

Then SharePoint 2013 came out – finally with .NET 4.0 runtime. I said cool, this should make it easy to host SignalR in the same domain and even in the same Application Pool as SharePoint 2013. Yepp, that’s the theory and SharePoint can sometimes make it a little bit harder than it should be (still, SharePoint 2013 is a rock star!!!).

SignalR Hub in SharePoint 2013

When you create a SignalR application you need a hub. A hub is a class with methods you can call from the clients or externally to notify other clients. In order to communicate all clients need to register on that hub. In normal world SignalR attaches to the App_Start event where it registers a route “~/signalr/hubs” so clients know the endpoint where they can talk to SignalR hubs or get the hub description file (proxy). With this behavior you have a problem:

There is no App_Start

(You could modify the global.asax – but I want a deployable solution…)

App_Start the SharePoint way

The only deployable way I could imagine to call a function once the app pool spins up  – with several farm nodes – is a http handler. Wait a http handler is call very often, we need to remember this one:

Now we need to add this module to the web.config farm wide – easiest way is the SPWebConfigModification  and a Web Application feature.

Note: The uninstalling method is not shown here, don’t forget it because the SPWebConfigModification remembers the changes!

With that the route will register – only once – and we should be all set right?

SharePoint 2013 yellow page of death

Nasty stack trace

Stack trace:    at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.IsExcludedPath(String virtualPath)

at Microsoft.SharePoint.ApplicationRuntime.SPVirtualPathProvider.DirectoryExists(String virtualPath)

at System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext)

at System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context)

at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

That doesn’t sound good.

SharePoint and the ~

SharePoint doesn’t like the tilde character. If you add a route (if you don’t, SignalR does) starting with ~, SharePoint shows the yellow page of death. The “easy” fix is to create a custom VirtualPathProvider  – I didn’t know what this class is doing before, too – and just pretend the ~ is not there:

Now register this little sweety in the previously created http module – two problems solved there now:

Okay – that’s it. Open the hub link and finally you get the hub proxy file!

SignalR hub proxy

Does not look too spectacular but a post will follow with some demos – now that I know how it works!

SignalR in SharePoint 2013 –  is there an easier way?!

Tell me in the comments and thanks for reading!

Max Melcher
Follow me!

Max Melcher

Maximilian Melcher (MCSE, MCPD) is a Principal Consultant working at Alegri International Services in Munich, Germany. Max is a specialist in SharePoint technologies focused on search, social computing, web content management and collaboration. Max has led SharePoint implementations for Dax 30 companies since 2009.
Max’s free time is spent on twitter (@maxmelcher) mostly with a good coffee in his hands.
Max Melcher
Follow me!
Tags: ,
24 replies
  1. Winson Kwok says:

    I’m using SharePoint 2013 RTM version and SignalR v1.0.0 RC1 (install through package manager). Following two steps must be done, otherwise the SharePoint Web site will fail to load:

    1. Add following modules into GAC(I think this will plug in the owin module into the SharePoint Server since SignalR is running on top of owin):

    Owin (v1.0)
    Microsoft.Aspnet.Signalr.owin (v1.0.0-rc1)
    Microsoft.Aspnset.Signalr.SystemWeb (v1.0.0-rc1)
    Microsoft.Owin.Host.systemWeb (v1.0.0-rc1)
    Microsoft.Web.Infrastructure (v1.0.0.0)
    Newtonsoft.Json (v4.5.11)

    We may need to uninstall/reinstall the above modules when new version of those modules are available!

    2. Insert following code into web.config file:

    under assemblybinding section

    This step is very important because without this code, the MapHubs method will reference incorrect version of module! The server will fail to load the module when the MapHubs method is called!

    • Max Melcher says:

      Thanks for your comments winson!

      My goal was it to deploy SignalR solutions farm wide – without touching the GAC or web.config manually.

      1. Just add the files to the package, they are deployed automatically. The OWIN stuff is new in > alpha2 – I didnt had the time to figure it out, but David Fowler told me its just an abstraction so I hope it should work without a fight.

      2. Apparently you can not post this here – do you mind dropping me a line (contact form)?

      Thanks again!

  2. Winson Kwok says:

    The code of the web.config file is:

    since it is missing from my previous comment

  3. Elliot Wood says:

    You should be able to use the following attribute to get access to “App_Start”.

    [assembly: PreApplicationStartMethod(typeof(MySignalRApplication.RegisterHubs), “Start”)]

    namespace MySignalRApplication
    public static class RegisterHubs
    public static void Start()
    // Register the default hubs route: ~/signalr/hubs

  4. mihai says:

    Great post, i wanted to use this after i used knockouts with sharepoint and rest calls and i really needed this great great.

  5. Cyrus says:

    Hi Following the above steps was able to make signalR hub work in SharePoint 2013 but there’s one problem . Once you execute RouteTable.Routes.MapHubs(); I start getting 401 error for /ScriptResource.axd?d=yOl74qUqOk94mP9XCpBRvuOVSwbwF_3l-6t9ZjW-

    and because of this sharepoint default jscript are failing.

  6. George says:

    I did all the steps and managed to create SignalR endppint.
    The only one thing that did not work is to resolve the Hubs.
    I created a class that iherits “Hub” type, but the …./signalr/hubs file does not generates the hubs, and also I tried to access the hub manually… both with no luck.

    What could be wrong ?

    • Max Melcher says:

      Hey George,

      is the hub in the same assembly as the SignalRModule?
      It has to be – otherwise the /signalr/hubs thing wont recognize the hub and wont generate the proxy for you.


  7. Sergei Sergeev says:

    Hi Max,
    Thanks for the great article!
    Do you have a blog post or solution for the new SignalR version?

    • Max Melcher says:

      Hey Sergei,

      thanks for the feedback – it depends what you are trying to do and what circumstances you are facing:

      a) You have only one port available and cannot create new iis applications: Use my solution, just replace the SignalR version with the current one.
      b) You can create new iis web applications on a different port? Just create the signalr application (app model!) outside and consume it within SharePoint.

      So long & Merry Christmas!

  8. Oliver says:

    Hi Max,

    I wrote a post for SP2013 (farm solution) and SignalR 2.2. – hope this helps:

    SP2013 and SignalR 2.2.



Trackbacks & Pingbacks

  1. […] example using SignalR 1.x, like this solution), and / or based on SharePoint 2013 (like the posts here, here or this CodePlex […]

  2. […] lines was fairly limited. One person who carried the torch was Maximilian Melcher – his post SignalR in SharePoint 2013 – the real-time web is coming! outlined that integrating SignalR in SharePoint 2013 wasn’t as easy as one might expect […]

  3. […] Video showing two webpages reflecting changes in a documentlibrary 1) […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.