views:

428

answers:

3

I am using a WebBrowser-Control to fill in a webform and then click at a button, this currently results in a standard Download File Dialog (you get these if you download a file using internet explorer), but instead, I have to catch this file and save it automatically with a by me defined name to a specific folder.

I am trying to code a little application in vb.net which download the Export-file from my wordpress-blog, and I want to do this completely without user-interaction.

Currently everything works, except the downloading of the file. I tried to catch it with the event System.Windows.Controls.WebBrowser.Navigating(ByVal Object, ByVal System.Windows.Navigation.NavigatingCancelEventArgs) but I don't see where to download the file from :(

I hope you guys can help me.

A: 

You could use Fiddler to capture the HTTP request that is used to get the file and just record the response. Then, you could save the response body to a file.

Fiddler has extensive support for automation.

Zian Choy
I am able to make the webbrowser-control to just download the page and not run any scripts and so on, but i don't find anything releated in the website-sourcecode that I could save - and if possible I dont want to use another 3rd party product
BasisBit
Fiddler is a development tool, you wouldn't be using it at run time. You could use this to capture the HTTP conversation between the browser and the web server, and then emulate that conversation using WebClient to send the HTTP requests
MarkJ
thanks! this brings me a lot closer to my goal - but I still have the problem with the form-login if I use webclient instead of webbrowser
BasisBit
sorry, but doesnt work :( It was to be inside the webbrowser control (I could also use advanced webbrowser-controls but all I tried didnt handle such downloads - why?) But another way would be to add text/xml as mime type in internet explorer so it will show it instead of downloading it - do you know how to change the mime types using vb.net or c#?
BasisBit
A: 

implement IServiceProvider on your webbrowser site and responde service queries to IDownloadManager

Sheng Jiang 蒋晟
Thanks for this help! I tried this ExtendedWebBrowser project, but I don't really know what I have to do with IDownloadManager or where in the code of the ExtendedWebBrowser I have to add this :(
BasisBit
Sheng Jiang 蒋晟
+1  A: 

Use WATIN. Very, very similar to the IE browser control, BUT it has all sorts of cool handlers for dialog pop ups, including security warnings and file download/save options.

ajl