NavigateToStream。用于解析相关链接什么的URI(如果有的话)? [英] NavigateToStream. What URI (if any) is used for resolving relative links?
问题描述
我有一个使用一个WPF应用程序中的< web浏览器>
对象来显示一些内容,而这又是包裹在HTML - 我要生成的是HTML飞翔,但它将保持链接到不同类型的静态内容,这将是本地文件。在一个正常的Web应用程序,我会尝试使用相对URI这个 - 他们将相对于动态页面的URI抬头
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.
问题是如果我使用 WebBrowser.NavigateToStream
(或 .NavigateToString
)。在这种情况下,什么是根URI用于解析相对链接?我可以控制它?难道是固定的吗?也许相对URI只是禁止在这样的数据流。
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.
推荐答案
尝试添加的 <基地HREF =root_path>
到< HEAD>
生成的页面的部分。它与 NavigateToString
,至少包括:
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>");
这篇关于NavigateToStream。用于解析相关链接什么的URI(如果有的话)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!