<%@ Page Language="C#" validateRequest="false" AutoEventWireup="true" CodeBehind="frmExcel.aspx.cs" Inherits="HDDZ.WEB.RealTime.frmExcel" %>
提交的内容是ExtJs grid生成的Excel 数据,xml格式的<html>
    <head>
        <title>从客户端(exportContent=&quot;&lt;xml version=&quot;1.0&quot; e...&quot;)中检测到有潜在危险的 Request.Form 值。</title>
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Lucida Console";font-size: .9em}
         .er {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
        </style>
    </head>    <body bgcolor="white">            <span><H1>“/scada5”应用程序中的服务器错误。<hr width=100% size=1 color=silver></H1>            <h2> <i>从客户端(exportContent=&quot;&lt;xml version=&quot;1.0&quot; e...&quot;)中检测到有潜在危险的 Request.Form 值。</i> </h2></span>            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">            <b> 说明: </b>请求验证过程检测到有潜在危险的客户端输入值,对请求的处理已经中止。该值可能指示存在危及应用程序安全的尝试,如跨站点脚本攻击。若要允许页面重写应用程序请求验证设置,请将 httpRuntime 配置节中的 requestValidationMode 特性设置为 requestValidationMode="2.0"。示例: &lt;httpRuntime requestValidationMode="2.0" /&gt;。设置此值后,可通过在 Page 指令或 &lt;pages&gt; 配置节中设置 validateRequest="false" 禁用请求验证。但是,在这种情况下,强烈建议应用程序显式检查所有输入。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkId=153133。
            <br><br>            <b> 异常详细信息: </b>System.Web.HttpRequestValidationException: 从客户端(exportContent=&quot;&lt;xml version=&quot;1.0&quot; e...&quot;)中检测到有潜在危险的 Request.Form 值。<br><br>            <b>源错误:</b> <br><br>            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code><pre>[没有相关的源行]</pre></code>                  </td>
               </tr>
            </table>            <br>            <b> 源文件: </b> c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\scada5\abdcae96\ca46d814\App_Web_ym1midaz.3.cs<b> &nbsp;&nbsp; 行: </b> 0
            <br><br>            <b>堆栈跟踪:</b> <br><br>            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code><pre>[HttpRequestValidationException (0x80004005): 从客户端(exportContent=&quot;&lt;xml version=&quot;1.0&quot; e...&quot;)中检测到有潜在危险的 Request.Form 值。]
   System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection) +8730740
   System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection) +122
   System.Web.HttpRequest.get_Form() +114
   System.Web.HttpRequest.get_HasForm() +8896111
   System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97
   System.Web.UI.Page.DeterminePostBackMode() +69
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253
   System.Web.UI.Page.ProcessRequest() +78
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.realtime_frmexcel_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\scada5\abdcae96\ca46d814\App_Web_ym1midaz.3.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +75
</pre></code>                  </td>
               </tr>
            </table>            <br>            <hr width=100% size=1 color=silver>            <b>版本信息:</b>&nbsp;Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.1            </font>    </body>
</html>
<!-- 
[HttpRequestValidationException]: 从客户端(exportContent=&quot;&lt;xml version=&quot;1.0&quot; e...&quot;)中检测到有潜在危险的 Request.Form 值。
   在 System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)
   在 System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection)
   在 System.Web.HttpRequest.get_Form()
   在 System.Web.HttpRequest.get_HasForm()
   在 System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull)
   在 System.Web.UI.Page.DeterminePostBackMode()
   在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   在 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   在 System.Web.UI.Page.ProcessRequest()
   在 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   在 System.Web.UI.Page.ProcessRequest(HttpContext context)
   在 ASP.realtime_frmexcel_aspx.ProcessRequest(HttpContext context) 位置 c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\scada5\abdcae96\ca46d814\App_Web_ym1midaz.3.cs:行号 0
   在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->

解决方案 »

  1.   

    enableEventValidation="false"加上试试
      

  2.   

    同意,一般情况下用FreeTextBox等也容易出现此问题
      

  3.   

    <%@ Page Language="C#" ValidateRequest="false" EnableEventValidation="false" AutoEventWireup="true" CodeBehind="frmExcel.aspx.cs" Inherits="HDDZ.WEB.RealTime.frmExcel" %>还是不行
      

  4.   

    都在扯淡!ValidateRequest="false" 
      

  5.   

    <%@ Page Language="C#" ValidateRequest="false" EnableEventValidation="false" AutoEventWireup="true" CodeBehind="frmExcel.aspx.cs" Inherits="HDDZ.WEB.RealTime.frmExcel" %> 
    这个就在被POSt的画面里。 frmExcel就是接受字符串生成Excel导出的
      

  6.   

    当使用 .net 4.0 时会出现此问题。解决步骤如下:
    1.将 httpRuntime 配置节中的 requestValidationMode 特性设置为 requestValidationMode="2.0"。
      示例: <httpRuntime requestValidationMode="2.0" />。
    2.在 Page 指令或 <pages> 配置节中设置 validateRequest="false" 禁用请求验证。在ASP.NET 4.0中,请求验证功能被提前到IHttpHandler.BeginRequest这个方法被请求之前,这也就意味着所有进入ASP.NET请求通道的所有的HTTP请求都将会被进行请求内容合法性的验证,包括有的自定义HttpHandler,WebService请求,甚至于利用自定义Http Module进行自定义请求处理程序。
    请求验证处理被提前的后果就是导致我们在页面,或者Controller中设置ValidateRequest=false,将会失效,无法阻止程序不去验证请求的输入内容了。因为这样做后,验证器无法得到请求的页面是否禁用了验证请求,因为还没有实例化HttpHandler。并且在ASP.NET4.0中,并没有提供给我一个地方去禁用这个验证功能。但是出于兼容性的考虑,ASP.NET允许我们通过在web.config中配置使用ASP.NET 2.0的请求验证行为:<httpRuntime requestValidationMode=”2.0″ />。
    以上资料来自 阿不 的blog,详细情况在:http://www.cnblogs.com/hjf1223/archive/2010/04/17/1714148.html