Question

I have a composite C1 site - working fine. Some pages use the MVC Player - which works fine - along with all pages on the site - except the Blog which causes a routing conflict.

Error: The incoming request does not match any route.
C1 Function: Composite.AspNet.MvcPlayer.Render
Error details:
Exception has been thrown by the target of an invocation.
The incoming request does not match any route.

This error appears at the top of the page - the blog works fine under the error - I just need to get rid of the cause of this error. I guess the MVC controller is trying to route the blog pages because it thinks they don't exist & can't find the controller.

How can I get the controller to ignore the blog - or fix this some other way?

Was it helpful?

Solution

Short answer is that both items (blog and mvc player) are fighting over the path portion of your URL. They both expect they own the path into bit to do routing.

Example: /en/Blog /2011/11/29/Chamonix-To-Courmayeur-Skiing-Day-Trips

The /en/Blog portion is routing you to the page hosting your blog, while the rest is path info that is passed along to any functions you may have hosted on the page. Since the path is "one thing" there is no distinction whether this string is intended for the blog function or the MVC Player function. This is what is creating the confusion.

Provided you wish to leave the blog as is you can work around this issue in two ways:

  1. Move the feature you have in MVC Player to another function provider, like Razor Functions
  2. Change the MVC Player so it does not pass the path info along to you MVC controller.

The second workaround can be done quick and dirty by editing ~/App_Code/Composite/AspNet/MvcPlayer/Player.cs and commenting out this line (line 57)

Path = PathInfo;

Before you do this note that this would impact all your running instances of MvcPlayer.

To create a new alternative MvcPlayer which does not rely on routing (leaving the original one intact) do this:

  1. Copy Player.cs to NoRoutePlayer.cs (and rename the class accordingly) and make the above mentioned change there (comment out line 57).
  2. Then register this new function in Composite C1 by going to Functions | C# Functions | Composite | AspNet | MvcPlayer and add a node here, using the existing Render element as inspiration. Just set the 'Type' name to NoRoutePlayer.

With that change you will have a Player function and a NonRoutingPlayer function and you can then use the latter to run your MVC controller, and everyone should get along just fine :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top