如何停止自动使用 Tag Helper?
How can i stop a Tag Helper automatically being used?
例如:我希望我的代码按原样呈现。相反,它会自动生成所有其他好东西。我如何为那个特定标签关闭标签助手?
您可以通过引用其完整类型名称来移除特定的 TagHelper,使其不再影响视图,即:
@removeTagHelper The.Full.TypeName.Of.The.TagHelper, TheAssemblyNameTheTagHelperExistsIn
或者,如果您想禁用程序集中的所有 TagHelper:
@removeTagHelper *, TheAssemblyNameTheTagHelperExistsIn
所以回到原点,如果您想禁用所有默认的 MVC TagHelper,您可以包含以下两行:
@* This nukes ~/ resolution and ITagHelperComponents (things running on body/head), this is an auto-inclusion in every view *@
@removeTagHelper *, Microsoft.AspNetCore.Mvc.Razor
@* These TagHelpers are typically included via a _ViewImports.cshtml. This nukes all of the MVC TagHelpers (environment, input with asp-for, etc.)*@
@removeTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
您可以在标签名称前添加一个!
以防止标签助手执行:
<!form method="post">
<button type="submit">Submit</button>
</!form>
例如:我希望我的代码按原样呈现。相反,它会自动生成所有其他好东西。我如何为那个特定标签关闭标签助手?
您可以通过引用其完整类型名称来移除特定的 TagHelper,使其不再影响视图,即:
@removeTagHelper The.Full.TypeName.Of.The.TagHelper, TheAssemblyNameTheTagHelperExistsIn
或者,如果您想禁用程序集中的所有 TagHelper:
@removeTagHelper *, TheAssemblyNameTheTagHelperExistsIn
所以回到原点,如果您想禁用所有默认的 MVC TagHelper,您可以包含以下两行:
@* This nukes ~/ resolution and ITagHelperComponents (things running on body/head), this is an auto-inclusion in every view *@
@removeTagHelper *, Microsoft.AspNetCore.Mvc.Razor
@* These TagHelpers are typically included via a _ViewImports.cshtml. This nukes all of the MVC TagHelpers (environment, input with asp-for, etc.)*@
@removeTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
您可以在标签名称前添加一个!
以防止标签助手执行:
<!form method="post">
<button type="submit">Submit</button>
</!form>