如何查看HttpWebRequest发送的标头 [英] How to view the headers sent by HttpWebRequest

查看:51
本文介绍了如何查看HttpWebRequest发送的标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HttpWebRequest抓取网站,但是该网站返回错误.当我从浏览器中点击该页面时,该页面运行良好.我想对它们进行比较,以查看可能导致该错误的原因.我知道如何拦截来自浏览器的请求以检查标头,但是如何查看HttpWebRequest发送的数据?

I'm scraping a site with HttpWebRequest, but the site is returning an error. The page works fine when I hit it from my browser. I'd like to compare them to see what may be causing the error. I know how to intercept the request from my browser to inspect the headers, but how do I view the data sent by HttpWebRequest?

推荐答案

为了比较您在代码中所做的工作以及浏览器的工作,我确定可以使用HTTP调试工具,例如

In order to compare what you do in code, and what the browser does, I am sure a HTTP debugging tool such as Fiddler, would be the easiest solution.

提琴手充当客户端和服务器之间的代理,并显示通过HTTP协议发送的所有信息.

Fiddler acts as a proxy between client and server, and displays all information sent over the HTTP protocol.

可能需要将.NET应用程序配置为使用Fiddler提供的代理.此博客文章提供了有关该主题的详细信息.

It is possible that you will need to configure your .NET app to use the proxy that Fiddler provides. This blog post provides details on the subject.

这篇关于如何查看HttpWebRequest发送的标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆