从客户端MVC4检测到潜在危险的Request.Form值 [英] A potentially dangerous Request.Form value was detected from the client MVC4

查看:112
本文介绍了从客户端MVC4检测到潜在危险的Request.Form值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在插入带有<"的记录时出现此错误.

i getting this error when inserting a record with "<".

如何通过使用<"插入字符串来解决此错误在里面. 我正在使用实体框架.该列的数据类型为nvarchar.

how to solve this error with inserting a string with "<" in it. im using entity framework. this column has a datatype of nvarchar.

提前谢谢.

推荐答案

您可以尝试在web.config

<system.web>
...
    <httpRuntime targetFramework="4.5" requestValidationMode="2.0" />
...
</system.web>

并用以下命令装饰您的控制器/动作(选择合适的一个):

And decorate your controller/action (choose the apropriate one) with:

[HttpPost]
[ValidateInput(false)]
public ActionResult MyMethod(string s)
{
    ....
}

注意:请始终清理您的输入内容.

Note: Always sanitize your input.

这篇关于从客户端MVC4检测到潜在危险的Request.Form值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆