简体   繁体   English

WebBrowser访问二进制内容

[英]WebBrowser access to binary content

I am trying to access the binary data of PDFs in my C# .NET 2.0 project. 我正在尝试在我的C#.NET 2.0项目中访问PDF的二进制数据。 I have a URL that points directly to the PDF, but I connot access the content through DocumentStream (which is null) . 我有一个直接指向PDF的URL,但是我没有通过DocumentStream (为null)访问内容。 I can't use an HttpWebRequest to get the PDF from this URL, because the server that the PDF is hosted on requires script-based authentication, which means I need to use a WebBrowser to do everything. 我无法使用HttpWebRequest从此URL获取PDF,因为托管PDF的服务器需要基于脚本的身份验证,这意味着我需要使用WebBrowser来完成所有操作。

The authentication is no problem (I already have it logging in); 身份验证没有问题(我已经登录了); I just need to have my already logged-in WebBrowser fetch these PDFs without any human interaction. 我只需要让我已经登录的WebBrowser无需人工干预即可获取这些PDF。 How can I access the PDF and save it to my local disk? 如何访问PDF并将其保存到本地磁盘?

This question is based on the following forum thread: http://bytes.com/topic/c-sharp/answers/505986-webbrowser-access-binary-content 该问题基于以下论坛主题: http : //bytes.com/topic/c-sharp/answers/505986-webbrowser-access-binary-content

Typically, the client stores logged-in state in cookies. 通常,客户端将登录状态存储在cookie中。 To send a request in a logged in state may require setting a cookie as well. 要以登录状态发送请求,可能还需要设置cookie。 You will have to look at the browser settings (or the explicit response on the log in script) to see what to set. 您必须查看浏览器设置(或登录脚本上的显式响应)以查看要设置的内容。

(It looks like CookieContainer is the relevant property for HttpWebRequest .) (看来CookieContainerHttpWebRequest的相关属性。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM