Does anybody have SignalR and Sitecore working together?
There is an issue in Sitecore with hitting the Application_Start in Sitecore and getting it to kickoff RouteTable.Routes.MapHubs().
I have double checked that I am mapping to my URL/signalR/hubs default on the layouts. The script blocks for JQuery, JQuery SignalR, and the custom JS are also included.
It pulls everything down fine on the Client Side, except that the URL/signalr/hubs is not mapping.
I have noticed some special handling needed in Sitecore for MVC RouteTables, but these do not directly address the issue currently experienced.
Thanks -
So after so working on this for a bit...
It was the simple thing that makes this work.
You have to add the /signalr and /signalr/hubs to the Ignore Path for SignalR to work with Sitecore.
<setting name="IgnoreUrlPrefixes" value="/sitecore/default.aspx|/trace.axd|.....|/signalr|/signalr/hubs" />
After I got that into place, I was able to see the MapHubs wire up correctly in the Application_Start. It would not consistently hit the break point before since it couldn't provide the URL without trying to get a Sitecore item. Now I see it hit the breakpoint consistently.
Thanks for the responses!
I'm assuming that you are using Sitecore 6.6 as you've mentioned the Sitecore MVC RouteTables. Try using WebActivator to register your hub mappings in the RouteTable. WebActivator gives you options to add this bootstrap code into either a PreApplicationStartMethod or a PostApplicationStartMethod so that you can register your routes and avoid Sitecore's wildcard route taking precedence. I have used this approach to bootstrap Web API routes under Sitecore.
using System;
[assembly: WebActivator.PreApplicationStartMethod(
typeof($rootnamespace$.App_Start.MySuperPackage), "PreStart")]
namespace $rootnamespace$.App_Start {
public static class MySuperPackage {
public static void PreStart() {
// Add your start logic here
}
}
}
An alternative approach would be to add the registration code into a custom pipeline processor and add this processor into the initialize event pipeline in App_Config\Include\Sitecore.Mvc.config
<pipelines>
<!-- Loader -->
<initialize>
<processor type="Sitecore.Mvc.Pipelines.Loader.InitializeGlobalFilters, Sitecore.Mvc"/>
<processor type="Sitecore.Mvc.Pipelines.Loader.InitializeControllerFactory, Sitecore.Mvc"/>
<processor type="Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc"/>
</initialize>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With