您的位置:首页 > 理论基础 > 计算机网络

System.Web.HttpRequestValidationException: 从客户端(XML="<?xml version=\"1.0\...")中检测到

2016-11-11 14:02 579 查看
调试webservices时的报的错误:测试数据如下:<?xml version="1.0" encoding="utf-8"?><body><head><userid>test</userid><password>123</password><trans_no>TCM301</trans_no></head><resquest><CENTRE_PRESID>2</CENTRE_PRESID><CLINIC_ID>2017120300176</CLINIC_ID><RECORD_TIME>2017-11-10 16:27:43</RECORD_TIME><EMP_ID>333</EMP_ID><DECOCTION_DAY>5555</DECOCTION_DAY><DEMAND>666</DEMAND><ORG_CODE>7777</ORG_CODE><PRES_LIST><NO>1</NO><TIMES>1</TIMES><GROUPNO>3</GROUPNO><DRUG_ID>4</DRUG_ID><DRUG_NAME>5</DRUG_NAME><QUANTITY>6</QUANTITY><REMARK>7</REMARK></PRES_LIST></resquest></body>普通数据诸如"abcsd",1112233之类的都能通过. 包含< ? 之类的就报错了.
System.Web.HttpRequestValidationException: 从客户端(XML="<?xml version=\"1.0\...")中检测到有潜在危险的 Request.Form 值。
   在 System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)
   在 System.Web.HttpRequest.<>c__DisplayClass280_0.<ValidateHttpValueCollection>b__0(String key, String value)
   在 System.Web.HttpValueCollection.EnsureKeyValidated(String key)
   在 System.Web.HttpValueCollection.Get(String name)
   在 System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
   在 System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request)
   在 System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
   在 System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

解决方案:
<system.web>
<httpRuntime requestValidationMode="2.0" />
<pages validateRequest="false"/>
<compilation debug="true" targetFramework="4.5.2">
<assemblies>
<add assembly="System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
</system.web>
参考如上,主要增加这俩个节点即可.
<httpRuntime requestValidationMode="2.0" />
<pages validateRequest="false"/>
案例二(客户端调用服务端webservices  解决方案同上.):
“/调用”应用程序中的服务器错误。从客户端(txtXmlText="<DATAPACKET><InputSe...")中检测到有潜在危险的 Request.Form 值。说明: ASP.NET 在请求中检测到包含潜在危险的数据,因为它可能包括 HTML 标记或脚本。该数据可能表示存在危及应用程序安全的尝试,如跨站点脚本攻击。如果此类型的输入适用于您的应用程序,则可包括明确允许的网页中的代码。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=212874。 异常详细信息: System.Web.HttpRequestValidationException: 从客户端(txtXmlText="<DATAPACKET><InputSe...")中检测到有潜在危险的 Request.Form 值。源错误:只有在调试模式下进行编译时,生成此未经处理的异常的源代码才会显示出来。若要启用此功能,请执行以下步骤之一,然后请求 URL:1. 在产生错误的文件的顶部添加一条“Debug=true”指令。例如:<%@ Page Language="C#" Debug="true" %>或:2. 将以下的节添加到应用程序的配置文件中:<configuration><system.web><compilation debug="true"/></system.web></configuration>请注意,第二个步骤将使给定应用程序中的所有文件在调试模式下进行编译;第一个步骤仅使该特定文件在调试模式下进行编译。重要事项: 以调试模式运行应用程序一定会产生内存/性能系统开销。在部署到生产方案之前,应确保应用程序调试已禁用。堆栈跟踪:[HttpRequestValidationException (0x80004005): 从客户端(txtXmlText="<DATAPACKET><InputSe...")中检测到有潜在危险的 Request.Form 值。]System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection) +9809768System.Web.HttpRequest.ValidateHttpValueCollection(HttpValueCollection collection, RequestValidationSource requestCollection) +194System.Web.HttpRequest.get_Form() +50System.Web.HttpRequest.get_HasForm() +9810059System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +95System.Web.UI.Page.DeterminePostBackMode() +69System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6607System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245System.Web.UI.Page.ProcessRequest() +72System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +22System.Web.UI.Page.ProcessRequest(HttpContext context) +58ASP.default_aspx.ProcessRequest(HttpContext context) +4System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +188System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.6.1055.0  

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐