请求验证过程检测到有潜在危险的客户端输入值,对请求的处理已经中止

HttpRunTime增加
requestValidationMode="2.0"
并在页面上设置
validateRequest="false" 
如果想只针对某些提交数据放行,可以这样写
public class RequestValidatorDisabled : System.Web.Util.RequestValidator
{
    protected override bool IsValidRequestString(System.Web.HttpContext context, string value, System.Web.Util.RequestValidationSource requestValidationSource, string collectionKey, out int validationFailureIndex)
    {
        if (value.IndexOf("<div>") >= 0)
        {
            validationFailureIndex = -1;
            return true;
        }
        else
        {
            return
            base.IsValidRequestString(context, value, requestValidationSource, collectionKey, out validationFailureIndex);
        }
    }
}

httpRunTime增加

requestValidationType="System.RequestValidatorDisabled"

 



posted @ 2020-05-21 17:35  zhaogaojian  阅读(290)  评论(0编辑  收藏  举报