在 asp.net Web 表单应用程序中,我们有时会收到一条错误消息,其中包含“潜在危险的 Request.RawUrl”,但我找不到它的来源。
出现此异常的可能原因是什么?
我们案例的一些细节:
Event message: A validation error has occurred Exception type: System.Web.HttpRequestValidationException Exception message: A potentially dangerous Request.RawUrl value was detected from the client (="..._Combin%20%20%20%20%20%2..."). Request URL: https://somesite/somepage.aspx ?_TSM_HiddenField_=ctl00_sm1_HiddenField &_TSM_Combin%20</div>%20%20%20%20%20%20%20%20<div%20id= Stack trace: at System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName) at System.Web.HttpRequest.get_RawUrl() 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.somepage_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
我在生成的页面的 html 中识别出带有 TSM_HiddenField 的部分:
<script src="/somepage.aspx?_TSM_HiddenField_=ctl00_sm1_HiddenField&_TSM_CombinedScripts_= %3b%3bAjaxControlToolkit%2c+Version%3d3.5.11119.20050%2c+Culture%3dneutral%2c +PublicKeyToken%3d28f01b0e84b6d53e%3ada-DK%3a8e147239-dd05-47b0-8fb3-f743a139f982 %3ae2e86ef9%3a1df13a87%3a8ccd9c1b%3ac4c00916%3a9ea3f0e2%3a9e8e87e9 %3a4c9865be%3aba594826%3ac76f1358" type="text/javascript"></script>
...所以本例中似乎与AjaxControlToolkit有关,但是这个异常怎么会发生呢?
(它发生在用户登录时,所以我怀疑是否涉及一些爬虫或黑客尝试......)
最佳答案
看起来您在提交的表单字段中有 HTML 标记,可能是这个:
&_TSM_Combin%20</div>%20%20%20%20%20%20%20%20<div%20id=
<div>
罪魁祸首就是他。
关于asp.net - "Potentially dangerous Request.RawUrl"的可能原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1629795/