The following code:
var canonical = new TagBuilder("link"); canonical.MergeAttribute("rel", "canonical"); canonical.MergeAttribute("href", url); return new MvcHtmlString(canonical.ToString());
Creates a tag:
<link href="http://local.domain.com/" rel="canonical"></link>
Is it possible to render
<link href="http://local.domain.com/" rel="canonical"/>
instead, using TagBuilder?
Have you tried:
canonical.ToString(TagRenderMode.SelfClosing);
You can also try.
TagBuilder tagBuilder = new TagBuilder("link"); tagBuilder.TagRenderMode = TagRenderMode.SelfClosing;
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