WebBrowser access to binary content

G

Guest

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 when I tell
my WebBrowser to retrieve it, it stalls and never finishes downloading
the document. 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 without stalling?
 
L

Luke Zhang [MSFT]

Hello,

Can you open ths PDF document directly in IE on the client? WebBrowser is
almost like an IE instance. To open a PDF document in IE, IE will first
download it in temp folder and then run Adobe Arcobat component, which may
be the root cause of the problem. So we may first try it in IE to see if it
can work.

Regards,

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
G

Guest

Yes, if I access the URL directly in IE it opens it in Acrobat.

I'd be happy if I could get the WebBrowser to save it as a local file with a
known name.
 
L

Luke Zhang [MSFT]

Can you open a PDF file in local disk, for example:

webBrowser1.Navigate("c:\\test.pdf");

Also, webBrowser didn't provide method Save() or SaveAs(), I think we still
need user interaction for save such a PDF file.

Regards,

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
G

Guest

That behaves the same as when I try to pull it from a remote location. The
browser stalls forever waiting for the document to complete.

It's fine if I can't save the PDF to disk; I really just need access in my
C# program to the binary stream.
 
L

Luke Zhang [MSFT]

Hello,

With WebBrowser control, we also cannot get the stream of a PDF file. (Even
it has a property named "DocumentStream", but it is null value when loading
a PDF file in the webbrowser control. So, I think the proper should be with
HttpWebRequest. Would you please let know what the script-based
authentication is (maybe with cookies or something else)? Maybe we can find
a way with this.

Regards,

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
G

Guest

On these sites there's a form on the log-in page with some text fields to
fill out and a link to click that invokes a javascript submit. From there on
it's up to the scripts running on the page to remember that the agent is
logged in. And since the scripts are actually running inside the browser
agent, it's really more like the agent is remembering this for itself. There
seem to be no cookies involved; it's all maintained in the browser's state.
Which means, as far as I can tell, for a component to be capable of logging
in, it needs to be able to run these scripts and keep track of enough log-in
information to please the server.

Any chance we can get an HttpWebRequest to pull this off?
 
L

Luke Zhang [MSFT]

Hello,

If the authentication tolally on client side, we may simulate the last
request to the server. I suggest you may trace the request, for example,
with Fiddler ( you may google with this to get download link, a very great
tool!). With these trace, we can get the exact request message the client
sent ( after authentication on client), and then use HttpWebRequest, or
HttpRequest to send a same request.

Regards,

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top