I am trying to load a local HTML file into an instance of C# WebBrowser (WinForms). This is what I am doing:
string url = @"file:///C:MyHtml/hello.html";
myWebbrowser.Url = new Uri(url, UriKind.Absolute);
object test = myWebbrowser.Url; // breakpoint here
The path above is correct; if I copy it and paste into an external browser, the file is immediately opened. But the instance of WebBrowser does not want to react. I set a breakpoint in the last line of the snippet, and what I get there is that myWebbrowser.Url
is null
(the test
variable). The control remains correspondingly empty.
myWebbrowser.AllowNavigation
is explicitly set to true
. I have also tried all possible versions of slashes and backslashes; the result is always the same. The version of the webbrowser seems to be 11 (myWebbrowser.Version
= "{11.0.18362.1139}"). I am working in Windows 10, VS 2019.
What can be wrong in this setup?