Question If I'm using the WebBrowser control to display a web page with a download link, how can I ensure the download/install happens when link is clicked?

Joined
Sep 16, 2023
Messages
20
Programming Experience
10+
WHAT I HAVE:
Visual Basic 2019, .NET Framework 4.6+, WinForms

MY PROBLEM:
I like to use the WebBrowser control, rather than simply firing up the browser, in order to ensure that a program's strategic access to the web doesn't serve as a substitute for the user simply firing up the browser at a specific page, and then navigating anywhere willy-nilly. The thing is, I want to use the control to send the user to a page with a download/install link. How can I ensure that when the link is clicked, the download/install actually takes place like it would if I simply fired up the browser?

If extra code is required, keep it in VB.NET and as simple as possible.
 
Your problem statement is not really a problem. It's an aim. What's the actual problem you're encountering? What is currently happening that you don't expect/desire or not happening that you do expect/desire?
 
Your problem statement is not really a problem. It's an aim. What's the actual problem you're encountering? What is currently happening that you don't expect/desire or not happening that you do expect/desire?

Actually, it's a question. If I use WebBrowser to display a web page with a link to download/install something, will the download/install take place when the user clicks on the link? I tried a sample program, and the answer appears to be yes (!!)--only you have to set ScriptErrorsSuppressed to True to avaid having to repeatedly click "Yes" to "Do you want to continue to run scripts on the page?" in response to a Scripting Error warning box.

There is one unsolved problem, though: If the form with the WebBrowser control is closed before the download and install is completed, the process aborts. Is there a way to wait until the process is completed before allowing the form to close? (I could have it repeatedly search for the downloaded app on my machine until it finds it present and then close the form, but that would create an infinite loop if the download/install fails, and that technique won't work if the app is already present beforehand!)
 
Last edited:
Back
Top