Is there a native way to convert Tagbuilder to String in Net Core? This only is for ASP Net 5. Convert IHtmlContent/TagBuilder to string in C#
Convert value of TagBuilder into a String
I think Microsoft had a replacement function for this in Net Core
public static string GetString(IHtmlContent content)
{
using (var writer = new System.IO.StringWriter())
{
content.WriteTo(writer, HtmlEncoder.Default);
return writer.ToString();
}
}
The same
WriteTomethod is available in aspnetcore.You should be able to continue to benefit from creating the same GetString method, as
TagBuilderinherits fromIHtmlContent.For example:
Then from your code, you can just call