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)

3
  • Have you tried AllowHtml attribute on your property in model class? Commented Aug 1, 2011 at 20:43
  • If you are using ASP.NET 4, refer to stackoverflow.com/questions/4361907/… Commented Aug 1, 2011 at 20:54
  • Thanks both of you. Had all of that done. However, had <httpRuntime requestValidationMode="2.0"/> under the new to 4.0 <runtime> element, rather than under <system.web>. I've no idea what feat of logic lead me to do that. But its all working now. Commented Aug 1, 2011 at 20:58

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Had <httpRuntime requestValidationMode="2.0"/> under the new to 4.0 <runtime> element. Moved it next to the <compiliation> element like the link and it all works now. Thanks :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.