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 h开发者_开发问答ref="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;
精彩评论