I use the WriteLiteral() method in a class derived from WebPageBase to produce some html output for a section. Everything works fine except, that the HTML code is printed as normal text and not interpreted as HTML tags. How can I write HTML code using the write/writeliteral methods of a WebPageBase?
Here some example code. I want the word “User” to be bold:
this.DefineSection("UserInfo", () =>
{
string username = "xyz";
this.WriteLiteral("<b>User:</b> " + username));
});
The problem was:
I rendered the Section into a var. And the output must be printed via Html.Raw(renderedSection).