httpwebrequest - 获取所有请求
我试图从我的 aspx 页面获取单个 httpwebrequest 范围内发生的请求列表。
使用 fiddler 时,您向 IE 请求页面。在执行该请求时,页面会请求 x 个其他文件作为请求的一部分。 Fiddler 向您显示您正在获取一个 .css 文件、一个 .js 文件,并且可能在渲染之前还从该页面请求其他几个页面。
我希望能够从我的 aspx 页面发出 httpwebrequest,然后监视(或列出)该请求中调用的 URL。
也就是说,我愿意接受其他方式来完成请求。例如 IFRAME 等。
也许这无法从 aspx 页面完成。有想法吗?
I'm trying to get the list of requests that occur within the confines of a single httpwebrequest from my aspx page.
When using fiddler, you request a page from IE. While doing that request the page requests x number of other files as part of the request. Fiddler shows you that you are getting a .css file, a .js file and maybe its's also requesting a couple other pages from that page before it renders.
I want to be able to make the httpwebrequest from my aspx page then monitor (or list out) the URLs that are being called within that request.
That said I am open to alternate ways to do the request. e.g. IFRAME, etc.
Maybe this just can't be done from an aspx page. Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在服务器上使用 HttpWebRequest,则它不会下载所有其他嵌入资源。如果您想获取页面上使用的资源列表,您必须自己解析 HTML。
以下是可能有用的相关问题: 如何使用 HTML Agility Pack 从网站检索所有图像?
If you are using an HttpWebRequest on the server, it is not going to download all of the other embedded resources. If you want to get the list of resources used on the page, you'll have to parse the HTML yourself.
Here's a related questions that might be useful: How can I use HTML Agility Pack to retrieve all the images from a website?
这不能从 ASPX 页面完成。我认为您应该挂钩 Global ASAX 事件之一(通过编写自定义 HttpModule)并拦截那里的请求。
This cannot be done from ASPX page. I think you should hook on one of the Global ASAX events (via writing custom HttpModule) and intercept the requests there.