I have uploaded all PDF files under media library. In one of my template, I added multilist with datasource to the pdf files which are created under media Library. Now in my code,I have to read the PDF files selected in the multilist from Sitecore.

I have added like below for the field in my Model.

public virtual IEnumerable<File> Documents { get; set; }

While reading the data from the GlassMapper it is throwing an exception as below.

Message = "Failed to map properties on to the Item"

Please suggest a way to read the PDF files from Sitecore using GlassMapper

2 Answers 2


You need to create a model first for your media items, e.g.:

public class MediaFile
    public virtual Stream File {get; set; }

    public virtual string MimeType { get; set; }

    public virtual string Title { get; set; }

    public virtual string Size { get; set; }

    public virtual string Extension { get; set; }  

and then use it in your model:

public virtual IEnumerable<MediaFile> Documents {get;set;}
  • What using statement is needed here for SitecoreClass?
    – Paul
    Commented Sep 18, 2018 at 7:26
  • 1
    using Glass.Sitecore.Mapper.Configuration.Attributes;
    – Marek Musielak
    Commented Sep 18, 2018 at 8:01

Depends what you need to do with those pdfs I would keep it as Item and used MediaManager to work with it

public virtual IEnumerable<Item> Documents { get; set; }

You can then use it like

foreach(var document in Model.Documents){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.