1

I'm using Visual Studio (Visual Basic) and I have a Webbrowser object and I was wondering how I could overwrite the IE error pages. By that I mean the pages such as "Can not load the webpage." and "Could not navigate to page." type errors. (The ones with the fat "i" icon by them in Win7)

noseratio
  • 59,932
  • 34
  • 208
  • 486
  • Not clear! You want to trap 404 etc, and show some other content instead? – Tony Hopkinson Oct 27 '13 at 00:17
  • Basically, I want to change the IE system error pages, for example, the page that shows up when the user is not connected to the internet. – user2924091 Oct 27 '13 at 01:07
  • You may try handling `WebBrowser.Navigating` (WinFroms `WebBrowser`) and check for URLs like `res://ieframe.dll/dnserror.htm#http://127.0.0.1:1111/`. If there's a match, re-navigate to a local URL of your choice, or do something like `WebBrowser.DocumentText = "custom error info"`. This is going to be IE version specific though. – noseratio Oct 27 '13 at 05:39
  • The proper way of doing it is to handle [NavigateError](http://msdn.microsoft.com/en-us/library/bb268221(v=vs.85).aspx) event. Check [this](http://stackoverflow.com/questions/880811/how-to-know-whether-webbrowser-navigating-a-error-page) and [this](http://stackoverflow.com/a/4225162/1768303) for more info. – noseratio Oct 27 '13 at 06:49
  • Well I just up voted, as it's an intriguing question. Pretty sure I would have done it outside of the browser control, but a method B is always nice. – Tony Hopkinson Oct 27 '13 at 10:54

1 Answers1

1

You can customize those error pages on the web server (IIS, Apache, etc.).

xpda
  • 15,585
  • 8
  • 51
  • 82
  • 2
    I guess the OP is asking how to override the IE default page which is shown when the server is not available. In which case, this doesn't help. E.g. try navigating to `http://127.0.0.1:1111`. The browser ends up with `res://ieframe.dll/dnserror.htm#http://127.0.0.1:1111/`. – noseratio Oct 27 '13 at 05:38
  • I see. It should be possible to try a connection first (outside the Webbrowser object) and display an error message if it cannot make a connection, and then loading the page in the Webbrowser object if the connection is available. – xpda Oct 27 '13 at 05:59
  • At least, there should be a reasonable timeout for connection test outside `WebBrowser`. Doing such check before every `WebBrowser` navigation request (which may be a link click or a form submit) would add significant wait and may be annoying for the user. The OP has actually asked a good question, I have no idea why it was down-voted. – noseratio Oct 27 '13 at 06:23