zoukankan      html  css  js  c++  java
  • MVC中”从客户端检测到有潜在危险的Request.Form值“的解决方法

    从客户端检测到有潜在危险的Request.Form值:

    在webForm中,可以在aspx页面顶部

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MaddAptitude.aspx.cs" Inherits="MaddAptitude" %>

    中加一句  ValidateRequest="false"  。

    或者在web.config文档<system.web>后面加入这一句: <pages validaterequest="false"/> ,例如:

    <configuration> 
        <system.web> 
            <pages validaterequest="false"/> 
        </system.web> 
    </configuration>
    

    在MVC中,可以在controller里面加 [ValidateInput(false)] ,例如:

       [ValidateInput(false)]  
        public class AdminController : Controller
        {
            ........
            return View();
        }
    

    如果还是不行的话,在web.config中加<httpRuntime requestValidationMode="2.0"/>,即:

    <configuration> 
        <system.web> 
            <httpRuntime requestValidationMode="2.0"/>
        </system.web> 
    </configuration>
  • 相关阅读:
    topcoder srm 681 div1
    topcoder srm 683 div1
    topcoder srm 684 div1
    topcoder srm 715 div1
    topcoder srm 685 div1
    topcoder srm 687 div1
    topcoder srm 688 div1
    topcoder srm 689 div1
    topcoder srm 686 div1
    topcoder srm 690 div1 -3
  • 原文地址:https://www.cnblogs.com/qk2014/p/3729739.html
Copyright © 2011-2022 走看看