Allowing HTML code for controller action method in ASP.NET MVC

Sheonarayan
Posted by Sheonarayan under ASP.NET MVC category on | Points: 40 | Views : 2473
There might be scenario, where we want to allow HTML code (Rich Text) as input to the Action method of the controller.

To do this, add ValidateInput attribute in the action method like below
[HttpPost]
[ValidateInput(false)]
public ActionResult Messages(FormCollection collection) {
// remaining code goes here
}


Hope this helps.

Comments or Responses

Posted by: Raja on: 7/23/2014 Level:Starter | Status: [Member] | Points: 10
This is what I was looking for!

Thanks
Posted by: Raja on: 7/23/2014 Level:Starter | Status: [Member] | Points: 10
Kindly keep submitting more posts.

Login to post response