0

I needs to find a way to allow html tags in MVC2 model binding.

In MVC3 there is a way but MVC2 I dont know. can you help?

In MVC3

[AllowHtml]
public string SomeProperty{ get; set; }

I need some alternate method for AllowHtmlAttribute in mvc2

lasitha edirisooriya
  • 793
  • 2
  • 13
  • 15

1 Answers1

1

You could use the [ValidateInput(false)] attribute on the controller action:

[ValidateInput(false)]
[HttpPost]
public ActionResult SomeAction(MyViewModel model)
{
    ...
}

This will disable input validation for all properties of the model. There's no way in ASP.NET MVC 2 to do this per property - it has to be for the entire request.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928