How to accept html input through textarea in ASP.NET MVC 2.0

I am using ASP.net MVC 2.0, I used a text box in my view as

<%= Html.TextAreaFor(m => m.Description, 7, 35, new { @class = "bg_area normal" })%> 

it shows me an exception when submitting the form after entering html data such as

 <p><b> hello world ! </b></p> 

Is there any way to accept such data using textarea?

Is there a way to process it from one place or should I add

[ValidateInput (false)]

for every action?

+4
source share
2 answers

I guess you get

The potentially dangerous value of Request.Form was detected from the client ... exception. IF so, then you need to decorate the result of the action with

 [ValidateInput(false)] 
+3
source

If you want to send HTML code to the Controller method, you need to add the [ValidateInput(false)] attribute to your controller method.

Here is the MSDN documentation .

+4
source

Source: https://habr.com/ru/post/1395783/


All Articles