We are trying to use custom contet providers to serve test content within our site (EiServer 7.5). We have a basic provider serving pages and now we want to create one to serve blocks.
I have mapped the block provider to a folder in the 'Blocks' media folder and it is being called when you navigate to the folder, however, we are getting the following error:
[KeyNotFoundException: The given key was not present in the dictionary.]
System.Collections.Generic.Dictionary`2.get_Item(TKey key) +14269699
EPiServer.Core.ContentProvider.GetScatteredContents(IEnumerable`1 contentLinks, ILanguageSelector selector) +693
EPiServer.Core.ContentProvider.LoadChildren(ContentReference contentLink, ILanguageSelector selector, Int32 startIndex, Int32 maxRows) +378
EPiServer.Core.DefaultContentLoader.GetChildren(ContentReference contentLink, ILanguageSelector selector, Int32 startIndex, Int32 maxRows) +1438
EPiServer.Core.DefaultContentLoader.GetChildren(ContentReference contentLink, ILanguageSelector selector) +98
We have overridden just the LoadContent and the LoadChildrenReferencesAndTypes methods, which is all we seamed to need to do for the page provider.
protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
if (contentLink.ID == 200000)
var contentType = ContentTypeRepository.Load();
var parent = _contentRepository.Get(new ContentReference(24397));
var block = GetDefaultContent(parent, contentType.ID, new LanguageSelector("en"));
((IContent)block).Name = "Test Block";
((IContent)block).ContentLink = new ContentReference(200000, "testBlocks");
var versionable = block as IVersionable;
if (versionable != null) versionable.Status = VersionStatus.Published;
protected override IList LoadChildrenReferencesAndTypes(ContentReference contentLink, string languageID, out bool languageSpecific)
languageSpecific = false;
IList result = new List();
if (contentLink.ID == 24397)
ContentLink = new ContentReference(200000),
IsLeafNode = true,
ModelType = typeof(ContentBlock)
I have had a look in GetScatteredContents via dotPeek and it seams to be trying to using the dictionary to lookup an index number from a ContentReference. I have overridden LoadContents, which is called just before this code and one of the arguments looks like it is created at the same time, but this is populated as I would expect.
Did you ever figure this out? Struggling with the exact same issue.
Sorry, No. We gave up on that plan in the end.