What is an MvcHtmlString and when should I use it?

The documentation for MvcHtmlString is not terribly enlightening:

Represents an HTML-encoded string that should not be encoded again.

It’s not clear to me what exactly the implications of this are. It seems that some HTML helper methods return an MvcHtmlString, but several examples I’ve seen online of custom helpers just return a regular string.

Questions:

What is an MvcHtmlString?

When should I choose MvcHtmlString over string and vice versa? Why?

4 Answers
4

Leave a Comment