I have a form with some checkbox type questions. The wording of the questions are fetched from a table in the DB. But there's HTML markup in them.
| ID {PK} | Question |
|---|---|
| 1 | What is your <strong> name <strong> ? |
| 2 | Another question with <br> HTML markup |
I can render these questions without trouble although they have HTML markup. The problem occurs when user submits the form.
@using (Html.BeginForm("SaveQuestion", "QuestionController", FormMethod.Post))
{
@for (int i = 0; i < Model.QuestionList.Count; i++)
{
@Html.HiddenFor(m => Model.QuestionList[i].ID)
@Html.HiddenFor(m => Model.QuestionList[i].Question)
<div>
@Html.CheckBoxFor(m => Model.QuestionList[i].IsDisplay)
@Html.DisplayFor(m => Model.QuestionList[i].Question)
</div>
}
<button type="submit">Save</button>
}
When the form is submitted I get the following error.
System.Web.HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client ....
The requirement force me to save these strings with markup in them. So how do I avoid this error? Is there a way to achieve the same with Unicode?