Html 打开图可以解析相对url吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9858577/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Open graph can resolve relative url?
提问by ebattulga
I'm adding Facebook Open Graph meta tag to my site. For example:
我正在向我的网站添加 Facebook Open Graph 元标记。例如:
<meta property="og:image" content="../images/aa.jpg"/>
Does Open Graph take relative URLs?
Open Graph 是否采用相对 URL?
Otherwise, how can I convert a relative urlto an absolute urlin asp.net mvc3- Is there any available function to do so?
否则,我怎么能转换成一个相对URL到一个绝对的URL在asp.net MVC3-是否有任何可用的功能,这样做呢?
采纳答案by Juicy Scripter
Documentation have nothing about it, but relative URLs will not work, only full URL including scheme works.
文档对此一无所知,但相对 URL 不起作用,只有包含方案的完整 URL 才有效。
As long as only full URLs supported you may convert relative to absolute url using URL.Content
method (as suggested in What is the equivalent to Page.ResolveUrl in ASP.NET MVC?)
只要只支持完整的 URL,您就可以使用URL.Content
方法相对于绝对 url 进行转换(如什么是 ASP.NET MVC 中的 Page.ResolveUrl 等价物?)
NOTES:
笔记:
- In 2012 in old Facebook bug tracker this bug was closed stating this is "by design" http://developers.facebook.com/bugs/192471680829756
- If you look into http://ogp.me/ns
og:image
specified asogc:url
which have next description:A string of Unicode characters forming a valid URL having the http or https scheme.
- 2012 年在旧的 Facebook 错误跟踪器中,此错误已关闭,说明这是“设计使然” http://developers.facebook.com/bugs/192471680829756
- 如果您查看指定为以下描述的http://ogp.me/ns:
og:image
ogc:url
形成具有 http 或 https 方案的有效 URL 的 Unicode 字符串字符串。
回答by Zonko
I set up an og:image
tag on my website with a relative url, and even though facebook reports an error like this :
我og:image
在我的网站上设置了一个带有相对 url的标签,即使 facebook 报告了这样的错误:
Object at URL 'http://***/' of type 'website' is invalid because the given value 'preview.png' for property 'og:image:url' could not be parsed as type 'url'.
位于 URL 'http://***/' 的类型为“website”的对象无效,因为无法将属性“og:image:url”的给定值“preview.png”解析为类型“url”。
on https://developers.facebook.com/tools/debug/og/object/, the image shows up in the preview.
在https://developers.facebook.com/tools/debug/og/object/ 上,图像显示在预览中。
So I guess this is kind of supported, at least on facebook.
所以我想这是一种支持,至少在 facebook 上。
回答by Chris
If you are setting the value of the og:url
meta node from within a Controller Action you can use:
如果您og:url
从控制器操作中设置元节点的值,您可以使用:
Request.Url.AbsoluteUri()
Request.Url.AbsoluteUri()