Open graph can resolve relative url?

HtmlFacebook OpengraphMeta TagsMeta

Html Problem Overview


I'm adding Facebook Open Graph meta tag to my site. For example:

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

Does Open Graph take relative URLs?

Otherwise, how can I convert a relative url to an absolute url in asp.net mvc3 - Is there any available function to do so?

Html Solutions


Solution 1 - Html

Documentation have nothing about it, but relative URLs will not work, only full URL including scheme works.

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?)

NOTES:

Solution 2 - Html

I set up an og:image tag on my website with a relative url, and even though facebook reports an error like this :

> 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'.

on https://developers.facebook.com/tools/debug/og/object/, the image shows up in the preview.

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

Solution 3 - Html

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

> Request.Url.AbsoluteUri()

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionebattulgaView Question on Stackoverflow
Solution 1 - HtmlJuicy ScripterView Answer on Stackoverflow
Solution 2 - HtmlZonkoView Answer on Stackoverflow
Solution 3 - HtmlChrisView Answer on Stackoverflow