ASP.NET 4.0 全局取消表单危险字符验证

转载自大圣的笑

原文链接:https://www.cnblogs.com/mahatmasmile/p/3872784.html

 
复制代码
    /// <summary>
    /// ASP.NET4.0 表单验证类
    /// </summary>
    public class FormRequestValidation : RequestValidator
    {
        public FormRequestValidation() { }

        protected override bool IsValidRequestString(HttpContext context, string value, RequestValidationSource requestValidationSource
            , string collectionKey, out int validationFailureIndex)
        {
            //不验证
            validationFailureIndex = -1; return true;
        }

    }
复制代码

web.config加上

  <system.web>
    <!--new 添加该节点对request.form的验证进行设定 -->
    <httpRuntime requestValidationType="namespace.FormRequestValidation" />
  </system.web>
posted @ 2019-11-15 18:44  小小的菜鸟程序员  阅读(177)  评论(0编辑  收藏  举报