Vulnerability in EPiServer.Forms
I want to search a block with specific property set to some value. This is my code:
var contentRepo = ServiceLocator.Current.GetInstance<IContentRepository>();
var allBlocks = contentRepo.GetDescendents(ContentReference.SiteBlockFolder);
foreach (var block in allBlocks)
var content = contentRepo.Get<BlockData>(block);
var subStepBlock = content as CertificationSubStepBlock;
if (subStepBlock != null)
if (subStepBlock.Code == code)
I am caching this, but is there a way to improve performances by search from specific block folder ID on? How would I see the ID of the folder in edit mode?
I guess you are not using EPiServer.Find in your project? Otherwise that would be the nicest solution.
From your pseudocode it looks like you are interested of a certain block type? If that is the case then you might want to use IContentModelUsage.ListContentOfContentType that will give you references to alll instances of your block type.
You would then still have to load and iterate over them to find which that matches your criteria, but with this approach you only load blocks of your wanted type and not all blocks as the case will be with GetDecendents.