';中的ASP.NET验证错误;组合脚本';?

';中的ASP.NET验证错误;组合脚本';?,asp.net,validation,Asp.net,Validation,我们有一个ASP.NET web表单应用程序,它偶尔会生成如下验证错误。 这是什么原因呢 A validation error has occurred. Exception type: System.Web.HttpRequestValidationException Exception message: A potentially dangerous Request.QueryString value was detected from the client (_TS

我们有一个ASP.NET web表单应用程序,它偶尔会生成如下验证错误。 这是什么原因呢

A validation error has occurred. Exception type: System.Web.HttpRequestValidationException Exception message: A potentially dangerous Request.QueryString value was detected from the client (_TSM_CombinedScripts_="... </div> ..."). Request URL: https://...:443/Default.aspx?_TSM_HiddenField_= ctl00_sm1_HiddenField&_TSM_CombinedScripts_= %3b%3bAjaxControlToolkit%2c+Version%3d3.5.11119.20050%2c +Culture%3dneutral%2c +PublicKeyToken%3d28f01b0e8%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 </div>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20<div%20class= Stack trace: at System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName) at System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, String collectionName) at System.Web.HttpRequest.get_QueryString() at System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) at System.Web.UI.Page.DeterminePostBackMode() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.user_default_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 发生验证错误。 异常类型:System.Web.HttpRequestValidationException 异常消息:潜在危险的Request.QueryString值 已从客户端检测到 (_TSM_CombinedScripts_uquo…)。 请求URL:https://...:443/Default.aspx?_TSM_HiddenField_= ctl00\u sm1\u隐藏字段和\u TSM\u组合脚本_= %3b%3bAjaxControlToolkit%2c+版本%3d3.5.11119.20050%2c +区域性%3dneutral%2c +PublicKeyToken%3d28f01b0e8%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20
%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ASP.NET默认情况下不允许在查询字符串或表单字段值中使用任何HTML(基本上是潜在危险值的列表)。这是由@Page指令的
ValidateRequest
属性设置的(默认情况下
true

您可以关闭该功能,但它会使您面临XSS攻击。更好的方法是确保所有查询字符串都是正确的URL编码


在您的情况下,似乎是
标记导致了问题。如果这个查询字符串是通过Javascript创建的,我建议使用该函数对值进行编码。

谢谢。我猜脚本块是由ASP.NET framework控件或AjaxControlToolkit控件生成的。我不知道如何控制。。。 <script src="/Default.aspx?_TSM_HiddenField_= ctl00_sm1_HiddenField&_TSM_CombinedScripts_= %3b%3bAjaxControlToolkit%2c+Version%3d3.5.11119.20050%2c +Culture%3dneutral%2c +PublicKeyToken%3d28f01c0e84b6d53e%3aen%3a7e147239-dd05-47b0-7fb3- f743a139f982%3be2e86bf9%3a1aa13a87%3a8ccd9c1b%3a9ea3f0e2%3a9e7e87e9 %3a4c9865be%3aba594826%3ac4c00916%3a630bb7c2%3af442e939" type="text/javascript"></script>