我使用的是ASP.NET 5.我需要将IHtmlContent转换为字符串
IIHtmlContent
是ASP.NET 5
Microsoft.AspNet.Html.Abstractions
名称空间的一部分,是TagBuilder
实现的接口
简化后的我有以下方法
public static IHtmlContent GetContent()
{
return new HtmlString("<tag>blah</tag>");
}
当我提到它的时候
string output = GetContent().ToString();
我得到了GetContent()的以下输出
"Microsoft.AspNet.Mvc.Rendering.TagBuilder"
而不是
<tag>blah</tag>
这是我想要的
我还try 使用StringBuilder
StringBuilder html = new StringBuilder();
html.Append(GetContent());
but it also appends the same namespace 而不是 the string value
我试着把它交给TagBuilder
TagBuilder content = (TagBuilder)GetContent();
但是TagBuilder没有转换为字符串的方法
如何将IHtmlContent或TagBuilder转换为字符串?