This is an example of how to modify the HeadTagHelper and the BodyTagHelper in ASP.NET MVC 2.0.
To get started, download Visual Studio 2017 and .NET Core 2.0.0 preview1.
Clone the repository and open the TagHelperComponentSample.sln
In the MyTagHelperComponent.cs
file, change the TagHelperOutput
to modify the <head>
or <body>
HTML element any way you want.
To learn more, head to Channel 9. A video tutorial will be posted soon!
To create a custom TagHelperComponentTagHelper
similar to the HeadTagHelper and the BodyTagHelper in ASP.NET Core MVC 2.0:
-
In the
MyTagHelper
file, change the[HtmlTargetElement]
to any HTML element of your choosing like the<p>
or<script>
tags. The sample uses<footer>
as an example, to modify all<footer>
tags in the application. -
In the
MyTagHelperComponent.cs
file, change theTagHelperOutput
to modify the<head>
or<body>
or the HTML element of your choice (the one you created in the step above) any way you want.
To learn more, head to Channel 9. A video tutorial will be posted soon!