Vulnerability in EPiServer.Forms
I have a listing page that pulls info from its child pages. Each child page has a property called 'Images' that is a ContentArea of blocks - with each block containing an 'Image' property. On the listing page, for each child page listed, I want to get the first block's Image property's src path. How would I do that? This is how I'm pulling in each child page...
@foreach (ReoListingPage listing in Model.Locations.Skip(Model.StartRowIndex).Take(Model.Count))
I hope that makes sense what I'm asking. Thank you!
1. Get the page
2. Get the content area property (images)
3. Use the content areas Items collection. Grab the first content item of the type you are looking for.
4. Use the Image property to render src. If this property is of type content or media you can use UrlResolver.GetUrl to get path.
Hope that helps
Thanks for the response Daniel. Unfortunately I am not an Epi expert. Could you expand on your response with code examples? The property is a media type. So within my foreach loop above, I would think I'd start with
but after that, I'm don't know.
var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
foreach (var contentAreaItem in currentPage.MainContentArea.FilteredItems)
var contentItem = contentLoader.Get<IContent>(contentAreaItem.ContentLink) as MediaData;
if (contentItem != null)
var url = UrlResolver.Current.GetUrl(contentItem);
...do something with the url. Fill custom viewmodel etc...
Something like that...took alloy start page as example. If you use FilteredItems you get support for visitor groups etc. I would probably put the above code in the controller and add it to the viewmodel in some custom field. A bit too much code to have in view in my point of view but thats a matter of taste...