For example: I want my tag to render as-is. Instead it is auto generating all the other goodies with it. How do i turn off Tag Helpers for that one specific tag?
You can add a !
before the tag name to prevent the tag helper from executing:
<!form method="post">
<button type="submit">Submit</button>
</!form>
Source
You can remove a specific TagHelper from impacting a view by referencing its full type name, i.e.:
@removeTagHelper The.Full.TypeName.Of.The.TagHelper, TheAssemblyNameTheTagHelperExistsIn
Alternatively if you want to disable all TagHelpers in an assembly:
@removeTagHelper *, TheAssemblyNameTheTagHelperExistsIn
So to come full circle, if you want to disable all default MVC TagHelpers you can include the two lines:
@* 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With