问题
I have an WPF application which uses a <WebBrowser> object to display some content which is in turn wrapped in HTML -- I want to generate that HTML on the fly, but it will hold links to different kinds of static content which will be local files.  In a normal web application, I would try to use relative URIs for this -- they will be looked up relative to the URI of the dynamic page.
The problem is if I use WebBrowser.NavigateToStream (or .NavigateToString).  In this case what is the "root" URI used for resolving relative links?  Can I control it?  Is it fixed?  Perhaps relative Uris are simply banned in such data streams.
回答1:
Try adding <base href="root_path"> into the <head> section of the generated page. It works with NavigateToString, at least:
this.webBrowser.NavigateToString(
    @"<head><base href='file://C:\Users\User\Documents\'></head><body><img src='image.jpg'></body>");
    来源:https://stackoverflow.com/questions/21259565/navigatetostream-what-uri-if-any-is-used-for-resolving-relative-links