Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValidateInput(bool) in ASP.NET Core

Tags:

In ASP.NET Framework when I want to pass HTML code from Javascript to Controller just wrote [ValidateInput(false)] before Method and no problem for me:

Just like my question here

I need to know same but ASP.NET Core.

Error CS0246 The type or namespace name 'ValidateInput' could not be found (are you missing a using directive or an assembly reference?)

Thanks

like image 319
Yuri Morales Avatar asked Nov 11 '16 16:11

Yuri Morales


1 Answers

In asp.net core you may not need to add this attribute, because, by default, the validation is not so strict as in ASP.NET MVC 4 or 5.

For example, passing HTML code via POST to a controller does throw an exception in older versions of ASP.NET(eg MVC 5)

A potentially dangerous Request.Form value was detected from the client

whereas in ASP.NET core, there is no exception.

like image 161
Pinte Dani Avatar answered Oct 17 '22 16:10

Pinte Dani