2

I have a product management page that contains a textarea in which some html is input for the description property of the product. This HTML fragment is stored in a database and displayed later on the product page.

The view HTTP POST's the model data back to the controller.

However, the controller constantly triggers a message: "A potentially dangerous Request.Form value was detected from the client". The only property triggering this message is the property containing the HTML fragment. This occurs even with all the validation turned off. The model, controller and the httpruntime element in web.config are all set to disable validation.

This leads me to the conclusion that i'm probabaly not handling the HTML values of the model correctly.

Any ideas for handling model properties that contain HTML, in both MVC and the database? (please base answers on MVC Music store tutorial)

Roberto Bonini
  • 7,164
  • 6
  • 39
  • 47
  • Have you tried AllowHtml attribute on your property in model class? – Vasea Aug 01 '11 at 20:43
  • If you are using ASP.NET 4, refer to http://stackoverflow.com/questions/4361907/asp-net-mvc-3-validaterequestfalse-not-working-with-formcollection – Tae-Sung Shin Aug 01 '11 at 20:54
  • Thanks both of you. Had all of that done. However, had under the new to 4.0 element, rather than under . I've no idea what feat of logic lead me to do that. But its all working now. – Roberto Bonini Aug 01 '11 at 20:58

1 Answers1

3

If you are using the latest version then you need to do some less than obvious magic to actually get validation turned off.

Community
  • 1
  • 1
alun
  • 3,393
  • 21
  • 26