0

In my web-browser control, I am invoking a click. I just loop through getElementsByTagName("INPUT") and for the submit one, I do obj.Click

All that button does is run a Javascript which does a postback by dynamically creating and posting a form with nothing more than ID=012345.

In Fiddler, the only thing that shows is that POST, though the return ContentType is application/pdf. Exactly what I want.

The kicker is... my WebBrowser is opening that content with Adobe instead of in the control! My goal is to save the PDF dynamically. In IE when I manually click the button, it opens in-window. If that were happening in my WebBrowser, I could save the document. Or, if I could catch the application/pdf return somehow, maybe I could save that?

Assumed Answer (Credit to Rick Mohr):

My team, as confirmed by Rick below, assume that the WebBrowser control uses some 32-bit mode code. So to fix the issue, you would have to be sure you are running your application with Platform Target: x86.

We didn't go through with it because this application interfaces with a lot of things, and we didn't see the ROI of the time to mitigate that. So I can't answer for sure, though I do believe Rick is correct.

So our solution was to use a one-off method using, something along the lines of HTTPWebRequest, to stream the object in. It isn't in-line with the rest of the project, but it certainly didn't break any dependancies, so it's good enough. :^)

Suamere
  • 5,691
  • 2
  • 44
  • 58
  • http://stackoverflow.com/questions/9195304/how-to-use-content-disposition-for-force-a-file-to-download-to-the-hard-drive – This isn't my real name May 07 '13 at 19:45
  • Thanks for the quick reply Elchonon, but I don't have a URL. The PDF is being dynamically created (probably by an ashx file on server-side), and sent back as a reply. There's never a .pdf file. But since it's returned as application/pdf, browsers can display them, or open them with adobe. From there they can be saved. – Suamere May 07 '13 at 19:57
  • My question has a header that says "This question may already have an answer here:..." Is that just for me to see? Or is that a suggestion by somebody? That thread is talking about httpresponse and posting headers from a web-server somebody is building. Completely unrelated. I'm just using a webbrowser in vb.net to view a public website that I have no control over. I can indeed READ their headers, which is how I got application/pdf as the content-type. If there is a way I can use that in my WebBrowser control, that would be great. – Suamere May 07 '13 at 22:36

1 Answers1

2

Are you on a 64-bit machine? The Adobe Reader DLL used by the WebBrowser control is 32-bit. When run in 64-bit mode it uses your Web Browser to open PDFs, as you're seeing. If you want it to work on a 64-bit machine, set your Platform target to "x86" instead of "Any CPU".

Rick Mohr
  • 1,821
  • 1
  • 19
  • 22
  • I'm not 101% sure that would fix it, though my team and I did assume that would be a solution. We didn't go through with it because this application interfaces with a lot of things, and we didn't see the ROI of the time to mitigate that. So I can't answer for sure, though I do believe you're correct. We instead just used a side-method using something like HTTPWebRequest (not sure which route they went) to stream the object in. It isn't in-line with the rest of the project, but it certainly didn't break any dependancies, so it's good enough. :^) – Suamere May 16 '13 at 15:14