tags:

views:

46

answers:

1

I am trying to access the binary data of PDFs in my C# .NET 2.0 project. I have a URL that points directly to the PDF, but I connot access the content through DocumentStream (which is 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.

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. How can I access the PDF and save it to my local disk?

This question is based on the following forum thread: http://bytes.com/topic/c-sharp/answers/505986-webbrowser-access-binary-content

A: 

Typically, the client stores logged-in state in cookies. To send a request in a logged in state may require setting a cookie as well. 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.)

Kathy Van Stone
Another problem might be what is in the Accept header. You need to make certain you accept binary content.
Kathy Van Stone