How do I block specific URLs in the WebBrowser? RRS feed


  • If you want to block specific URLs in the WebBrowser, you can use the event handler to set limits on WebBrowser Navigating events.  When the WebBrowserNavigatingEventArgs.Url equals the URL you want to block, we can set the WebBrowserNavigatingEventArgs.Cancel to true, so that the navigating action of the WebBrowser will be canceled.  

    Here is the code sample:


    private void webBrowser1_Navigating(object sender,  WebBrowserNavigatingEventArgs e)
         if (e.Url.Equals("http://www.microsoft.com"))
             e.Cancel = true;


    Related thread:


    For more FAQ about Visual C# General, please see Visual C# General FAQ


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.


    Wednesday, April 8, 2009 3:25 AM