The tag helper ‘input’ must not have C# in the element’s attribute declaration area
If you don’t need to use the TagHelper, you can use <!elementName> to disable it for a specific element: <!textarea class=”testClass” asp-for=”testId” @readonlyAttribute>@Model.Id</!textarea> See @glenn223’s answer for a more structural solution. I made an improved version of his solution, by adding support for anonymous objects: using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Razor.TagHelpers; namespace {YourBaseNameSpace}.Helpers.TagHelpers { [HtmlTargetElement(Attributes = “custom-attributes”)] … Read more