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?
ToHtmlString? Also, where do you getIHtmlContentfrom?HtmlStringclass's method. Can you point me to the documentation forIHtmlContent? It doesn't seem to be on MSDN