title: How to display images from local disk in mvc4?
body: <p>In my MVC(4) application, I'm fetching the image files from the local directory and displaying it in the browser.</p>
  
  <p>I've a <code>model</code> to store the details,and a <code>controller</code> to get the files and a <code>view</code> to display them.</p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>public class ImageModel
  {
      List&lt;string&gt; _images = new List&lt;string&gt;();
  
      public ImageModel()
      {
          _images = new List&lt;string&gt;();
      }
  
      public List&lt;string&gt; Images
      {
          get { return _images; }
          set { _images = value; }
      }
  }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public ActionResult Index()
  {
      var imageFiles = new ImageModel();
      imageFiles.Images.AddRange(Directory.GetFiles(@"c:\mypath"));
      return View(imageFiles);
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>@for (int imgIndex = 0; imgIndex &lt; Model.Images.Count; imgIndex++)
  {
      &lt;div &gt;
        &lt;img src = @Model.Images[imgIndex] alt="Image"  /&gt;
      &lt;/div&gt;
  }
  </code></pre>
  
  <p>But I can not view the images in the browser, its showing empty boxes with <code>alt</code>.</p>
  
  <p>What did I miss here? Should I create a virtual directory instead of physical location. </p>