1

This is probably a simply routing issue but after a quick google I haven't clicked as to what I am doing wrong with the routing.

When using SignalR the routing MapConnection corrupts the default MVC route renderings.

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

// default MVC
routes.MapRoute("Default", // Route name
  "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
  );
// SignalR routing
routes.MapConnection<EventConnection>("echo", "echo/{*operation}");

In this order I get a 404 when SignalR js client connects to /echo/ url.

If I swap the default MVC and SignalR routing around, the SignalR js client connects to /echo/ url and SignalR functions correctly but the Routes are rewritten incorrectly when rendered to the view i.e.

/echo?action=Index&controller=Home

Am I missing something obvious? I am looking at ExclusionConstraints to exclude the echo path but this seems heavy handed, surely there is a simplier way?


Also, I have tried using Regex contraint like in the following question which doesn't work.

MVC2 Routing with WCF ServiceRoute: Html.ActionLink rendering incorrect links!

laser
  • 1,388
  • 13
  • 14
JTew
  • 3,149
  • 3
  • 31
  • 39

1 Answers1

0

I ended up fixing this in the SignalR code using the below answer and submitting a pull request.

Html.ActionLink construct wrong link when a non-mvc route is added

https://github.com/SignalR/SignalR/pull/19

Community
  • 1
  • 1
JTew
  • 3,149
  • 3
  • 31
  • 39