C# and AxWebBrowser

Posted on 2004-11-10
Last Modified: 2008-01-09

I am using AxWebBrowser to access web pages from within my application.  I have two problems facing me off at the moment.

1.  Is there a method to intercept a 404 response prior to redirection (if any)?
2.  If the URL specified to the AxWebBrowser includes a filedownload of any description, how do I intercept this? (I don't want to enable this!)

Is it me, or is there not a great deal of documentation on the AxWebBrowser?!

I'd appreciate any help that can be offered.

Question by:Si-clone
    LVL 5

    Accepted Solution

    1st answer : use NavigateError event of axWebBrowser as shown below. (i assume that there is a label on the form named label1)

    private void axWebBrowser1_NavigateError(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateErrorEvent e)
          if ((int)e.statusCode == 404)
                label1.Text="not found";                        

    2nd answer : Try to use FileDownload of Web Browser control. There is an event argument class named e. This class has a property named cancel. Set cancel property to true. (Not tested)

    Hope this helps.
    Burak SARICA

    Author Comment

    Thanks for your reply.

    I had previously tried the FileDownload event, but it didn't seem to fire.  However, on closer examination it appears that what I need to trap was a Java window offering to download a CAB file.  Maybe this is why the FileDownload event did not fire?!

    One further question if I may :-)

    Do you know the difference between events such as NewWindow2 and NewWindow3?

    Thanks for your help.

    LVL 5

    Expert Comment

    NewWindow is an event on older versions of internet explorer that raises when a new window is to be created. NewWindow2 is the newer version of this event. It uses the same arguments but it works better. Because of this MSDN says "NewWindow is obsolete, use NewWindow2 instead". The NewWindow3 extends the event NewWindow2 and it supplies you with more information about the newly created window such as URL of the page opening the new window and URL being opened etc.

    Hope this helps.
    Burak SARICA

    Author Comment

    Thanks for your help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now