Aridane Álamo
Aridane Álamo

Reputation: 334

Asp.Net MVC AllowHtml attribute fails on postback

I am having troubles trying to use a rich text editor in Asp.Net MVC.

Actually I have the field that contains the RTF marked with the [AllowHtml] attribute and it's working right in the model binder, so I get the html value in the post method of the action.

But then, while rendering the response, in the layout page we access another property of the request directly using ViewContext.HttpContext.Request.Params["paramname"] and there it throws an HttpRequestValidationException because of the value of the text field, even if it's not the form parameter we are trying to access.

Any clue about how to avoid this?

Upvotes: 1

Views: 918

Answers (1)

Mufaka
Mufaka

Reputation: 3444

You can use the Request.Unvalidated property to get the value without triggering validation.

Upvotes: 2

Related Questions