为什么请求在googlebot抓取时会抛出异常,但在粘贴到网址时则不会抛出异常?

时间:2011-12-13 09:00:02

标签: asp.net-mvc iis-7 googlebot

我在事件日志中得到了大量的这些例外。

EVENT ID: 1309

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 12/12/2011 1:40:41 PM 
Event time (UTC): 12/12/2011 8:40:41 PM 
Event ID: f85f113a40d349f5a1fe9ef481038281 
Event sequence: 8993 
Event occurrence: 1463 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/12/ROOT-1-129681577057031250 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: C:\inetpub\wwwroot\gouki\ 
    Machine name: GOUKIPRIME 

Process information: 
    Process ID: 7508 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\gouki 

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)



Request information: 
    Request URL: http://gouki.com/Story/?page=8&orderby=views&tagged=&subject=&author=?page=10&orderby=views,views,views,&tagged=,,,,,,,,,,,,&subject=,,,,,,,,,,,,,,,,,,&author=,,,,,,,,,,,,,, 
    Request path: /Story/?page=8&orderby=views&tagged=&subject=&author= 
    User host address: 66.249.68.81 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: IIS APPPOOL\gouki 

Thread information: 
    Thread ID: 142 
    Thread account name: IIS APPPOOL\gouki 
    Is impersonating: False 
    Stack trace:    at System.Web.HttpRequest.ValidateInputIfRequiredByConfig()
   at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)


Custom event details: 

Connection: Keep-alive
Accept: */*
Accept-Encoding: gzip,deflate
From: googlebot(at)googlebot.com
Host: gouki.com
User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

我不确定googlebot在哪里收到格式错误的网址(我试图在我的网站上无法复制),但我更加好奇的是为什么会将此异常记录到事件日志中如果我自己复制/粘贴网址(继续,尝试),我没有错误。是的,页面有点破碎,因为参数值没有意义,我可以看到为什么双重问号可能会导致问题,但没有抛出异常。我已经尝试将我的用户代理更改为googlebot,但我仍然没有看到错误。

出于某种原因Asp.net MVC正在看第一个?作为路径的一部分而不是查询字符串的开头,但仅在googlebot请求页面时。

在这里我是否有某种逃避行为,我在事件日志中没有看到?

2 个答案:

答案 0 :(得分:2)

请注意:

Request path: /Story/?page=8&orderby=views&tagged=&subject=&author=

服务器认为查询字符串参数是页面名称的一部分,这可能意味着第一个问号实际上是使用%3f转义的,但在错误消息中没有显示。问号作为查询字符串的分隔符有效,但不作为页面名称的一部分。

僵尸程序已经在某处获取了URL,并且可能尝试修复它。确保您已正确转义了网址,即当网址位于HTML元素的属性中时,&应为&

如果您的页面中有?page=8&orderby=views&tagged=&subject=&author=之类的相对链接,则机器人可能会尝试通过将其与当前页面URL组合来创建完整的URL,这可以解释双重查询字符串集。这应该可以正常工作,但是如果URL的转义存在一些问题,可能会搞砸它。

答案 1 :(得分:0)