While HTML encoding content is often a good best practice,
there are times when the content you are outputting is meant to be HTML or is
already encoded – in which case you don’t want to HTML encode it again.
ASP.NET 4 introduces a new IHtmlString interface (along with
a concrete implementation: HtmlString) that you can implement on types to
indicate that its value is already properly encoded (or otherwise examined) for
displaying as HTML, and that therefore the value should not be HTML-encoded
again. The <%: %> code-nugget syntax checks for the presence of the
IHtmlString interface and will not HTML encode the output of the code
expression if its value implements this interface. This allows developers
to avoid having to decide on a per-case basis whether to use <%= %> or
<%: %> code-nuggets. Instead you can always use <%: %> code
nuggets, and then have any properties or data-types that are already HTML
encoded implement the IHtmlString interface.