Using SignalR 2.2 in a SharePoint 2013 farm solution

122
Views

In order to properly integrate SignalR with a SharePoint 2013 farm solution you have to make two types of changes to the typical SignalR boilerplate code: Change the Startup.cs and make a couple of web.config modifications.

Please note that this sample assumes that you are using SignalR 2.2, which in turn references OWin 2.1. In case you are using a newer version, make sure to adapt the assembly version numbers in the code snippets below accordingly (Version=2.1.0.0).

Startup.cs class

Add the DefaultAssemblyLocator to your Startup.cs, it is needed to locate and load your hub class in SharePoint:

GlobalHost.DependencyResolver.Register(typeof(IAssemblyLocator),() => new DefaultAssemblyLocator());

A sample Startup.cs would look like this:

SharePoint web.config modifications

In your web.config, make the following changes (use SPWebConfigModification for a proper deployment):

a) App settings

b) Add the OWin handler, so that the hub path is handled by Owin/SignalR (e.g. “/signalr/hubs”)

c) Remove or comment the “ExtensionlessUrl” entries in the handlers section. This is needed so that IIS can handle the hub path at all (e.g. “/signalr/hubs”)

d) Change the legacyCasModel to FALSE

e) Optional: If there is already a version of OWin installed, make sure to also add an assembly binding redirect to load the new versions:

Final points

Verify in your application page or custom web part that the order of the JavaScript includes is as follows:

…and you are good to go!

Alternative

An alternative Approach would be to generate the JavaScript file once. Look in the SignalrR docs for “How to create a physical file for the SignalR generated Proxy”.

*** This post has been originally posted on my blog ***

(122)

No ratings yet.

Please rate this

Using SignalR 2.2 in a SharePoint 2013 farm solution

| Development, SharePoint | 2 Comments
Profile photo of Oliver Pistor
About The Author
- Array

2 Comments

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">