title: Unable to loop inside media Folder in Umbraco 8
body: <p>I have 2 images in a media folder and I need to display them. I've been trying to loop inside the folder but have not been unable to.</p>
  
  <p>That's my code:</p>
  
  <pre><code>  var media = Model.Value&lt;IEnumerable&lt;IPublishedContent&gt;&gt;("mediaFolder");
  
      foreach (var item in media){
      &lt;img src="@item.Url"/&gt;
      }
  </code></pre>
  
  <p>The result is a compilation error:</p>
  
  <blockquote>
    <p>Exception Details: System.NullReferenceException: Object reference not
    set to an instance of an object.</p>
  </blockquote>