I am using ASP.NET 5. I need to convert IHtmlContent to String
IIHtmlContent
is part of the ASP.NET 5
Microsoft.AspNet.Html.Abstractions
namespace and is an interface that TagBuilder
implements
Simplified I have the following method
public static IHtmlContent GetContent()
{
return new HtmlString("<tag>blah</tag>");
}
When I reference it
string output = GetContent().ToString();
I get the following output for GetContent()
"Microsoft.AspNet.Mvc.Rendering.TagBuilder"
and not
<tag>blah</tag>
which I want
I also tried using StringBuilder
StringBuilder html = new StringBuilder();
html.Append(GetContent());
but it also appends the same namespace and not the string value
I tried to cast it to TagBuilder
TagBuilder content = (TagBuilder)GetContent();
but TagBuilder doesn't have a method that converts to string
How do I convert IHtmlContent or TagBuilder to a string?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…