OrchardCMS/OrchardCore · error · InvalidOperationException

Cannot override href with other properties

Error message

Cannot override href with other properties

What it means

The Liquid `a` tag in Orchard Core's DisplayManagement throws this when you supply an explicit `href` attribute AND at least one of the href-composing bound attributes (`protocol`, `host`, `fragment`, or non-empty `routeValues`). The tag cannot decide whether to honor your href or rebuild it from the other properties, so it fails fast instead of silently producing a wrong URL.

Solutions

  1. Remove the explicit `href` attribute and let the tag build the URL from `protocol`/`host`/`fragment`/`route_values`.
  2. If the literal href is what you want, drop the `fragment`, `host`, `protocol`, and `route_values` arguments and just append the fragment directly into the href string.
  3. Render a plain `<a>` element instead of the Liquid `a` tag if you need full manual control of the href.

Example fix

// before
{% a href:'/docs', fragment:'intro' %}Docs{% enda %}
// after
{% a href:'/docs#intro' %}Docs{% enda %}
// or let the tag compose it
{% a controller:'Docs', action:'Index', fragment:'intro' %}Docs{% enda %}
Defensive patterns

Strategy: validation

Validate before calling

{% if fragment or host or protocol or route_values %}
  {% if href %}{{ /* href combined with href-composing attributes: invalid */ }}{% endif %}
{% endif %}

Prevention

When it happens

Trigger: Writing `{% a href:'/x', fragment:'top' %}` or `{% a href:'/x', route_values: id, ... %}` in a Liquid template — i.e. `href` combined with any of `protocol`, `host`, `fragment`, or `route_values` having count > 0.

Common situations: Porting an existing plain HTML anchor into a Liquid `a` tag and leaving `href` in place while adding `fragment`/`host` for convenience; copy-pasting tag snippets where a base href is kept and route values appended; conditional templates where one branch sets href and another sets route_values but both end up bound.

Related errors


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

Appendix: source

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

            }
        }

        // If "href" is already set, it means the user is attempting to use a normal anchor.
        if (!string.IsNullOrEmpty(href))
        {
            if (action != null ||
                controller != null ||
                area != null ||
                page != null ||
                pageHandler != null ||
                route != null ||
                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);

View on GitHub (pinned to 4306c0717f)