开发者

ASP.NET MVC3: Alternatives to using ValidateInput

开发者 https://www.devze.com 2023-04-12 08:18 出处:网络
We are working on an ASP.NET MVC3 project that utilizes lots of html forms. Because of ValidateInput=true, < and > characters are forbidden through the site (except html enabled fields (AllowHtml)

We are working on an ASP.NET MVC3 project that utilizes lots of html forms.

Because of ValidateInput=true, < and > characters are forbidden through the site (except html enabled fields (AllowHtml)).

But instead of having server throw "A potentially dangerous Request.Form value was detected from the client" error, we want to catch the error and return an error in modelstate, highlighting the field and saying "You can not use < and > characters".

Is there an easy way to do this or do we have to turn validateinput to false and manually (or by a custom filter) check and imple开发者_StackOverflow社区ment this for each post function?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号