lasitha edirisooriya
lasitha edirisooriya

Reputation: 793

How do I turn off request validation in MVC2?

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

Upvotes: 0

Views: 160

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038930

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.

Upvotes: 1

Related Questions