3

I am having a similar problem to InvalidOperationException: No route in the route table matches the supplied values

That is, I am getting the error:

No route in the route table matches the supplied values

On a Content Delivery Server because I have disabled Sitecore.Speak.Mvc.config (I have confirmed, if I enable this config, my code works).

My problem is this. The code that is failing is using:

@Html.Sitecore().Controller(GlobalControllers.Page.Name, GlobalControllers.Page.Actions.HeadHTML) 

The above SO thread suggests manually adding the route, as in:

RouteTable.Routes.MapRoute(
    "Bogus-Required-Route",
    "bogus-required-route/{controller}/{action}",
);

But I'm not actually calling a route. I'm just feeding the controller name and action, so I would need to add just the basic route:

RouteTable.Routes.MapRoute(
    {controller}/{action}",
);

But doesn't that route already exist? If I add if for CDs, won't it blow up on the CM where I have the config enabled? What's the downside to just enabling this config on the CD?

4

As stated in the SO answer, the real issue is that without enabling the Sitecore.Speak.MVC.config, there's no route pattern matching just {controller}/{action}.

The answer that will solve your problem is that you need to enable a config on the Content Delivery Servers that enable this route.

There are a couple ways you can do this:

Option 1: Enable Sitecore.Speak.MVC.config

Let's take look at what this config is doing:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <initialize>
        <processor type="Sitecore.Mvc.Pipelines.Initialize.InitializeCommandRoute, Sitecore.Speak.Client" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']"/>
      </initialize>
      <mvc.renderPlaceholder>
        <processor type="Sitecore.Mvc.Pipelines.Response.RenderPlaceholder.RenderAddedContent, Sitecore.Speak.Client"/>
      </mvc.renderPlaceholder>
    </pipelines>
    <mvc>
      <precompilation>
        <assemblies>
          <assemblyIdentity name="Sitecore.Speak.Web" />
        </assemblies>
      </precompilation>
    </mvc>
  </sitecore>
</configuration>

This config is doing three things:

  • Initializing the Command Route (which is really the piece you need)
  • Adding a <renderPlaceholder> processor that renders added content.
  • Adds the Sitecore.Speak.Web assembly to the list of precompiled assemblies.

So, in a nutshell, there isn't much here that will harm a CD if this config is enabled, but the last two points aren't needed by the Content Delivery server.

Option 2: Enable Command Route Manually

You can create a patch config that patches in the InitializeCommandRoute processor above to the <initialize> pipeline. If this patch config exists on the CM, where this processor is already defined, it won't conflict.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <initialize>
        <processor type="Sitecore.Mvc.Pipelines.Initialize.InitializeCommandRoute, Sitecore.Speak.Client" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']"/>
      </initialize>
    </pipelines>
  </sitecore>
</configuration>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.