Why I got the error: The tag helper 'body' must not have C# in the element's attribute declaration area

Why I got the error: The tag helper 'body' must not have C# in the element's attribute declaration area

我已经从

更改了我的 _Layout.cshtml 文件中我的纯正体元素
<body data-my-attibute='myattributevalue'>

<body  @myAttributes>

并收到一条错误消息:

Severity Code Description Project File Line Suppression State Error RZ1031 The tag helper 'body' must not have C# in the element's attribute declaration area.

body 元素看起来和行为都不像标签助手 简而言之:H E L P,这是周五下午我背上的一把刀...

好吧,这很遗憾,但我要离开这里,它有可能对某人有所帮助...

@removeTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper, Microsoft.AspNetCore.Mvc.Razor

我有类似的问题,我从文档中了解到您可以通过在单个标签上添加 ! 来禁用标签助手,因此您的代码将是:

<!body  @myAttributes>
</!body>