You need to add the ValidateInputAttribute
to your controller (which applies it to all your action methods for that controller, so be careful):
[ValidateInput (false)] public class MyController : Controller { ... }
Or your action method:
public class MyOtherController : Controller { [ValidateInput (false)] public ActionResult MyActionMethod (MyObjectThatTakesInHtml myObject) { ... } }
Edit
As @dotjoe noted, and I forgot to mention, you also have access to the AllowHtmlAttribute
(found in System.Web.Mvc
) by the property in your model.
public class MyObjectThatTakesInHtml { [AllowHtml] public string MyHtmlProperty { get; set; } }
source share