OrchardCMS/OrchardCore · error · InvalidOperationException

Format of the link cannot be determined based on the…

Error message

Format of the link cannot be determined based on the available argument of the a tag

What it means

The Liquid `a` tag can build its URL in exactly one of three ways: from `route`, from `controller`/`action`, or from `page`/`page-handler`. When arguments from two or more of these groups are present simultaneously, the tag cannot determine which link format to produce and throws. Exactly one link-generation style must be used per tag.

Solutions

  1. Keep only one link style: either `route`, or `action` (+ optional `controller`), or `page` (+ optional `page_handler`) — delete the others.
  2. If you need route values with an action link, pass them via `route_values` (not `route`); `route_values` is a dictionary of parameters, `route` selects a named route.
  3. Split into two separate anchors if you genuinely intended two different link targets.

Example fix

// before
{% a route:'custom-route', action:'Index', controller:'Home' %}Home{% enda %}
// after
{% a action:'Index', controller:'Home' %}Home{% enda %}
// or
{% a route:'custom-route' %}Home{% enda %}
Defensive patterns

Strategy: validation

Validate before calling

// Ensure exactly one of route | action/controller | page/page-handler is set before rendering the tag
var styles = new[] { hasRoute, hasAction, hasPage }.Count(x => x);
if (styles > 1) throw new InvalidOperationException("Pick exactly one link style for the a tag");

Prevention

When it happens

Trigger: `{% a route:'x', action:'Index' %}`, `{% a route:'x', page:'About' %}`, or `{% a action:'Index', page:'Privacy' %}` — any combination where routeLink && actionLink, routeLink && pageLink, or actionLink && pageLink is true.

Common situations: Migrating MVC anchor-tag-helper usage (where `asp-route` coexisted with `asp-action`) into the Liquid tag; combining a named route with an action thinking they merge; adding `page` for Razor Pages while leaving a leftover `action` argument.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/a52bc7a8ea683ab0. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Tags/AnchorTag.cs:122

                protocol != null ||
                host != null ||
                fragment != null ||
                (routeValues != null && routeValues.Count > 0))
            {
                // User specified an href and one of the bound attributes; can't determine the href attribute.
                throw new InvalidOperationException("Cannot override href with other properties");
            }

            return Completion.Normal;
        }

        var routeLink = route != null;
        var actionLink = controller != null || action != null;
        var pageLink = page != null || pageHandler != null;

        if ((routeLink && actionLink) || (routeLink && pageLink) || (actionLink && pageLink))
        {
            throw new InvalidOperationException("Format of the link cannot be determined based on the available argument of the a tag");
        }

        RouteValueDictionary localRouteValues = null;
        if (routeValues != null && routeValues.Count > 0)
        {
            localRouteValues = new RouteValueDictionary(routeValues);
        }

        if (area != null)
        {
            // Unconditionally replace any value from asp-route-area.
            localRouteValues ??= [];
            localRouteValues["area"] = area;
        }

        TagBuilder tagBuilder;
        if (pageLink)
        {

View on GitHub (pinned to 4306c0717f)