Open graph can resolve relative url?

我正在给我的网站添加 Facebook Open Graph 元标签,例如:

<meta property="og:image" content="../images/aa.jpg"/>

Open Graph 是否采用相对 URL?

否则,在 asp.net mvc3中如何将 相对网址转换为 绝对网址-是否有可用的函数来做到这一点?

49494 次浏览

文档没有关于它的任何东西,但相对 URL 将不工作,只有完整的 URL 包括方案工作。

只要只支持完整的 URL,您可以使用 URL.Content方法(如在 在 ASP.NET MVC 中,什么等价于 Page.ResolveUrl?中所建议的)相对于绝对 URL 进行转换

备注:

形成具有 http 或 https 方案的有效 URL 的 Unicode 字符串。

If you are setting the value of the og:url meta node from within a Controller Action you can use:

Request.Url.AbsoluteUri()

我在我的网站上设置了一个 og:image标签和一个相对的 url,即使 facebook 报告了一个如下的错误:

对象在 URL“ http://* * */”类型为“ site”的对象无效,因为属性“ og: image: URL”的给定值“ preview.png”无法解析为类型为“ URL”。

https://developers.facebook.com/tools/debug/og/object/上,图像显示在预览中。

So I guess this is kind of supported, at least on facebook.