none
Webbrowser Control Downloads

    Question

  • I was wondering if there was a way to get a download before Internet Explorer pops up to download a file with the web browser control. I looked around the internet but couldn't find the answer. For instance when you create a web browser using the web browser control and you go to a downloadable link IE pops up with the download, I want to have my own form pop up with the download so i can handle the download myself.
    Thursday, May 13, 2010 11:25 AM

Answers

  • That's what I am suggesting. Let me reiterate.

    The documentation of IDownloadManager says you can hook up your own download manager that is effective in your webbrowser control host process by implementing IServiceProvider in the control site and implement QueryService to return an IDownloadManager object when asked for the service.

    In Windows Form's Webbrowser class, a control site is created for you by default, but you can override the control site by create your own WebBrowserSiteBase class and override the WebBrowser.CreateWebBrowserSiteBase Method.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
    Visual C++ MVP
    • Marked as answer by Steve82291 Wednesday, May 26, 2010 11:24 PM
    Thursday, May 20, 2010 4:48 PM

All replies

  • Hello,

    Please, take a look at this: http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.filedownload(v=VS.100).aspx

    If it's helpful, let me know, since I'd really could use it myself. Unfortunately, I have no VS in my work machine to test it...


    hth,
    Marcelo
    If my post solved you problem, please mark it as an "Answer". This way, other users that have the same questions will know how to proceed. If my post helped you some way, don't forget to score it as useful.
    Thursday, May 13, 2010 12:11 PM
  • It does tell you when the control is attempting to download the problem is that it pops up every time the browser navigates because as the browser navigates it is downloading web pages. I need something that will only catch file downloads and cancel the IE download popup, I'm pretty sure if i got the code to catch the download i could stop the IE popup with e.Cancel = true;
    Thursday, May 13, 2010 1:16 PM
  • Yes you need to install a download manager. There is no wrapper in Windows Forms so you need to port the native IDownloadManager interface and hook it to your webbrowser site. 

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
    Visual C++ MVP
    • Marked as answer by Harry Zhu Thursday, May 20, 2010 6:45 AM
    • Unmarked as answer by Steve82291 Thursday, May 20, 2010 3:15 PM
    Monday, May 17, 2010 3:02 AM
  • I don't understand how that answers the question, I have a Web Browser already, useing the webbrowser control. What i was trying to do was make a download manager for the web browser instead of using the one that comes with the web browser control.
    Thursday, May 20, 2010 3:17 PM
  • That's what I am suggesting. Let me reiterate.

    The documentation of IDownloadManager says you can hook up your own download manager that is effective in your webbrowser control host process by implementing IServiceProvider in the control site and implement QueryService to return an IDownloadManager object when asked for the service.

    In Windows Form's Webbrowser class, a control site is created for you by default, but you can override the control site by create your own WebBrowserSiteBase class and override the WebBrowser.CreateWebBrowserSiteBase Method.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
    Visual C++ MVP
    • Marked as answer by Steve82291 Wednesday, May 26, 2010 11:24 PM
    Thursday, May 20, 2010 4:48 PM
  • Sheng,

    you mean something like this?

    http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-interop/8051/IDownloadManager

     


    Hope this helps, Marcelo
    Thursday, May 20, 2010 5:02 PM
  • That's the managed version nof IDownloadManager. You need to implement the interface to do the actual downloading.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
    Visual C++ MVP
    Thursday, May 20, 2010 5:48 PM
  • Sorry, missed that. Anyway, I believe that if Steve82291 bing or google for IDownloadManager C#, he'll get the stuff he's looking at.

    Thank you for helping. In the end, I'm also benefiting from it :-)


    Hope this helps, Marcelo
    Thursday, May 20, 2010 6:17 PM