I’m writing some custom Html Helpers for my MVC3 and soon MVC4 project. Examples on the net usually show that it’s done with MvcHtmlString, however, I read that if we are using .NET 4, we should be using HtmlString.
What should I use and why?
Thanks.
Always use the highest possible interface/class in the hierarchy when designing something. In this case it’s IHtmlString and you could use it in ASP.NET MVC 3 and 4.
Be careful when returning an
IHtmlStringinstance from your helper. This means that it is up to you to properly HTML encode it: