I am trying to display HTML files (containing local images) in a WebBrowser control. User can select the file using an OpenFileDialog, after which it is displayed in the control.
But I have these problems I am struggling to solve:
-
Since I’ve added the control to my
Form, it’s been loading really slowly. It takes almost 10s for the form to instantiate. -
WebBrowser.Navigateonly works the first time. When I try to load the second file, nothing happens. I have tried callingRefresh,Update,OpenNew, openingabout:blankbetween two files, but I just don’t have a clue how to do it properly. Only the initially opened file remains shown, no exceptions or warnings ever pop up when I try to navigate to a different page.
Am I doing something wrong? For example, Lutz Roeder’s Writer starts instantly and loads subsequent files without problems, but it uses lots of interop (and is editable), so I am trying to avoid all that stuff.
The way I have been loading local
.htmlfiles into aWebBrowseris like so:It can load files one after another with no problems. If you are trying to load a big html file when the form is initializing or is opening this could explain the 10 second loading time. My form loaded almost instantly when it had a
WebBrowsercontrol on it.Hope this helps!
Edit: Try setting the stream of the
WebBrowser: