Suppresses the Save / Open dialog box in a WebBrowser control

I have a WebBrowser control that automatically logs me into a website and tries to download CSV data automatically. Everything works fine, except when it tries to load CSV data, a dialog box appears asking if I want to save the file or open it (as in IE). What I'm trying to do is automatically load the CSV file into a file of my choice (or is it better to save the CSV file directly in a string variable). I cannot figure out how to suppress the dialog box and automatically load the download. I searched and found some solutions, however they do not work for me because:

1) Now I am using the GUI. All this is done in the class (therefore methods like SendKeys will not be a viable solution)

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

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

+3
source share
3 answers

Sheng Jiang solutions are the best if you are familiar with the internal components of C ++.

, iMacros Internet Explorer (= ). , Windows hooks IE.

+2

IDownloadManager, . Windows Forms , WebBrowser.CreateWebBrowserSiteBase . . -.

+4

You cannot suppress the file download dialog, as this will be a serious security risk. I suggest you explore other routes to get your request authenticated if you want to make this process automatic.

0
source

Source: https://habr.com/ru/post/1760920/


All Articles