Suppressing the Save/Open Dialog box in a WebBrowser control

18,057

You can hook up your own IDownloadManager implementation that does download quietly. For Windows Forms, this means you need to override the WebBrowser.CreateWebBrowserSiteBase method to provide your extended control site. Check Webbrowser Control Downloads for details.

Share:
18,057
Icemanind
Author by

Icemanind

I am a .NET developer. I am proficient in C# and I use ASP.Net Core, Winforms and WPF. I also dabble in React and Xamarin.

Updated on June 04, 2022

Comments

  • Icemanind
    Icemanind almost 2 years

    I have a WebBrowser control that is automatically logging me into a website and attempting to download CSV data automatically. Everything is working fine, except, when it tries to download the CSV data, it is popping up a dialog box, asking if I want to save the file or open it (just like in IE). What I am trying to do is automatically download the CSV file to a file of my choosing (or better, save the CSV file directly into a string variable). I can't seem to figure out how to suppress the dialog box and capture the download automatically. I've search and found a few solutions, however, they don't work for me because:

    1) I am now using a GUI. All this is done in a class (therefore, methods such as SendKeys would not be a viable solution)

    2) The download comes from a secure site and requires authentication. The WebBrowser control handles all that for me, but if I use a WebRequest and WebResponse to try to capture the download, I am no longer authenticated.

    I am using C#. Any help would be appreciated.