asp.net 从客户端(:)检测到具有潜在危险的Request.Path值

apeeds0o  于 2022-12-15  发布在  .NET
关注(0)|答案(2)|浏览(194)

我在生产服务器上遇到了一个奇怪的问题,而在所有其他环境(DEV,UAT)上都工作正常。
当我跟踪日志文件时,我发现只有一个错误:

Exception information: 
    Exception type: HttpException 
    Exception message: A potentially dangerous Request.Path value was detected from the client (:).
   at System.Web.HttpRequest.ValidateInputIfRequiredByConfig()
   at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)

有没有人能告诉我,那边缺了什么。

vmdwslir

vmdwslir1#

由于内置的请求验证,您将获得此信息。您可以通过删除配置文件中的“:”来获得此信息:

> <system.web>
>     <httpRuntime requestPathInvalidCharacters="<,>,*,%,&,:,\,?" /> </system.web>

这是同一版本上的detailed article

yacmzcpb

yacmzcpb2#

我发现,如果在请求路径中有以/tel:结尾的内容,就会导致错误。
比如说

<a href="tel:123456">Call ME!</a>

我发现您可以通过删除href链接来解决此问题,并改为使用此链接

<div onclick="window.open('tel:123456');"  
     style="cursor: pointer;">Call ME!</div>

相关问题