If you're using TagBuilder extensively in any MVC5 project, you'll eventually use SetInnerText and InnerHtml.
These always felt a bit awkward to use. ASP.NET Core MVC fixes that, but with another somewhat odd InnerHtml property which uses IHtmlContentBuilder. This collects encoded and unencoded strings and renders the entire contents using WriteTo.
The end result of this "improvement" is that your existing code is incompatible. Enjoy! Maybe in the grand scheme of things (i.e., MVC6), this is the better way, but at the expense of compatibility. It's disappointing that this new version of ASP.NET Core MVC does not seem to care about compatibility.
Here is how you could get the inner html if you want it as a string:
namespace YetaWF.Core.Support {
public static class TagBuilderExtension {
...clipped...
public static string GetInnerHtml(this TagBuilder tagBuilder) {
using (var writer = new System.IO.StringWriter()) {
tagBuilder.InnerHtml.WriteTo(writer, HtmlEncoder.Default);
return writer.ToString();
}
}
}
}