ASP.NET MVC Head Verb 和 Selenium RC

发布于 2024-09-02 06:25:01 字数 606 浏览 2 评论 0原文

Selenium (RC) 用于测试 ASP.NET 1.1 站点。

当我们通过 Selenium RC 发出请求时(它又通过配置的浏览器(在本例中为 Firefox)自动执行请求),http 动词是“HEAD”。我们有几种表单操作方法,它们具有分别用 AcceptVerbs(HttpVerbs.Get) 或 HttpVerbs.Post 修饰的单独 GET 和 POST 方法。这些方法返回 404 并记录“找不到公共操作方法”错误消息。

问题:

  • 在编写单独的 Get/Post 操作方法时,处理中心动词的最佳实践是什么?我们是否应该始终用 AcceptVerbs(HttpVerbs.Get | HttpVerbs.Head) 进行装饰?

  • 为什么当 Selenium RC 自动化浏览器时生成 HEAD 动词来代替 If-Modified-Since 标头?

    为什么
  • 我们还看到来自使用 HEAD 动词的(非主流)爬虫的日志条目。我们创建了 robots.txt 条目来阻止这些爬虫对网站建立索引,但现在我们想知道从 SEO 角度来看最佳实践是什么。对于爬虫来说响应 HEAD 重要吗?有主流的爬虫使用它吗?它会影响 SEO 排名吗?

Selenium (RC) is being used to test an ASP.NET 1.1 site.

When we make a request via Selenium RC (which in turn automates the request via a configured browser - in this case Firefox) the http verb is "HEAD". We have several form action methods that have separate GET and POST methods decorated with AcceptVerbs(HttpVerbs.Get) or HttpVerbs.Post respectively. These methods are returning a 404 and logging a "a public action method could not be found" error message.

Questions:

  • When writing separate Get/Post action methods what is the best practice for handling the Head verb? Should we always decorate with an AcceptVerbs(HttpVerbs.Get | HttpVerbs.Head)?

  • Why is the HEAD verb being generated when Selenium RC is automating the browser in lieu of an If-Modified-Since header?

  • We've also seen log entries from (non-mainstream) crawlers that are using the HEAD verb. We created robots.txt entries to stop these crawlers from indexing the site, but now we're wondering what the best practice from an SEO perspective is as well. Is it important to respond to HEAD for crawlers? Are there mainstream crawlers that use it? Does it impact SEO rank?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸短情长 2024-09-09 06:25:01
  1. 是的,我认为每当您将请求限制为仅 GET 时,您都应该始终允许 HEAD - 事实上,我确实认为它应该内置到 MVC 框架中(下一步在我的待办事项列表中:在 MVC bug 跟踪器中提出 [HttpGet] 属性应该以某种方式支持 HEAD 动词的问题)
  2. 我也想知道这个问题的答案。同时,有建议的解决方法 - 传递 'true ' 作为 Selenium 的 open() 的第二个参数。
  3. 我不认为它会影响 SERP 排名本身,但是我可以看到如果 HEAD 给出 404,爬虫程序将不会请求完整页面。根据 HTTP 规范 (RFC2616), "HEAD 方法与 GET 相同,只是服务器不得在响应中返回消息正文”,因此,如果您做得正确 - 允许该方法并避免不列出应该不是问题。
  1. Yes, I think that whenever you are restricting your requests to be GET only, you should always allow HEAD on them as well - in fact, I do think it should be built into the MVC framework (next thing on my todo list: raise the issue in MVC bug tracker that [HttpGet] attribute should somehow support HEAD verb)
  2. I would like to know an answer to this too. In the meantime, there is a suggested workaround - pass 'true' as a second param to Selenium's open().
  3. I don't think it impacts SERP ranking per se, however I can see how crawlers would not request the full page if HEAD gives a 404. According to the HTTP spec (RFC2616), "The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response", so, if you are doing things right - it shouldn't be a problem to allow the method and avoid getting unlisted.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文