{"record":{"id":"1228e2b79a7b0853","repo":"OrchardCMS/OrchardCore","slug":"cannot-override-href-with-other-properties","errorCode":null,"errorMessage":"Cannot override href with other properties","messagePattern":"Cannot override href with other properties","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Tags/AnchorTag.cs","lineNumber":110,"sourceCode":"            }\n        }\n\n        // If \"href\" is already set, it means the user is attempting to use a normal anchor.\n        if (!string.IsNullOrEmpty(href))\n        {\n            if (action != null ||\n                controller != null ||\n                area != null ||\n                page != null ||\n                pageHandler != null ||\n                route != null ||\n                protocol != null ||\n                host != null ||\n                fragment != null ||\n                (routeValues != null && routeValues.Count > 0))\n            {\n                // User specified an href and one of the bound attributes; can't determine the href attribute.\n                throw new InvalidOperationException(\"Cannot override href with other properties\");\n            }\n\n            return Completion.Normal;\n        }\n\n        var routeLink = route != null;\n        var actionLink = controller != null || action != null;\n        var pageLink = page != null || pageHandler != null;\n\n        if ((routeLink && actionLink) || (routeLink && pageLink) || (actionLink && pageLink))\n        {\n            throw new InvalidOperationException(\"Format of the link cannot be determined based on the available argument of the a tag\");\n        }\n\n        RouteValueDictionary localRouteValues = null;\n        if (routeValues != null && routeValues.Count > 0)\n        {\n            localRouteValues = new RouteValueDictionary(routeValues);","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Tags/AnchorTag.cs#L92-L128","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove the explicit `href` attribute and let the tag build the URL from `protocol`/`host`/`fragment`/`route_values`.","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.","Render a plain `<a>` element instead of the Liquid `a` tag if you need full manual control of the href."],"exampleFix":"// before\n{% a href:'/docs', fragment:'intro' %}Docs{% enda %}\n// after\n{% a href:'/docs#intro' %}Docs{% enda %}\n// or let the tag compose it\n{% a controller:'Docs', action:'Index', fragment:'intro' %}Docs{% enda %}","handlingStrategy":"validation","validationCode":"{% if fragment or host or protocol or route_values %}\n  {% if href %}{{ /* href combined with href-composing attributes: invalid */ }}{% endif %}\n{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never mix `href` with `protocol`, `host`, `fragment`, or `route_values` in the same `{% a %}` tag.","Compose fragment/host directly into the href string when a literal URL is intended.","Prefer action/page/route arguments over raw href so the tag builds correct local URLs."],"tags":["liquid","razor-tags","invalid-argument","orchardcore"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}