Why does this works ?
[ContentType(DisplayName = "MyBlock ", GUID = "eccd619a-827c-4b13-b0c8-28c671f0f949", Description = "")]
public class MyBlock : BlockData
public virtual string CmsBlockName
return (this as IContent).Name;
I looked everywhere and none of the ancestors of MyBlock implements IContent. So why am I able to get the name on the content block by doing this ?
All shared blocks will implement the IContent interface at runtime.Local blocks won't.
If you call CmsBlockName on a local block, you'll get null reference exception.
I would suggest this code instead:
public static class BlockHelpers
public static string GetName(this BlockData block)
var content = block as IContent;
Good to know! Thank you.
As Dejan points out is blocks a special kind of content in meaning they can both be a property on other content (local blocks) or be an own instance (shared block). Here is a post that describes how shared blocks are built up.