EPiServer CMS with Facebook Open Graph

I just implemented support for the Open Graph protocol on an EPiServer CMS site to improve Facebook Share and Facebook Like.

First thing noticed is that it looks that Facebook have problem with national characters like ÅÄÖ and other Unicode characters when sharing or liking a page. At least sometimes. I think they change and improve their platform because things that worked before stopped working just a few days ago.

Facebook can not handle UTF-8 with Byte Order Mark (BOM)

ASP.NET and EPiServer CMS platform uses UTF-8 to encode content and the Emit UTF-8 identifier-flag is true by default and this adds the Unicode Byte Order mark first in the output stream. This is not really needed for UTF-8 and can causes problem.

It is easy to remove the BOM by adding one line of code to your master page.

public partial class MasterPage : System.Web.UI.MasterPage { protected override void OnInit(EventArgs e) { base.OnInit(e); Response.ContentEncoding =

new System.Text.UTF8Encoding(false); }