title: How to display saved image in a folder in ASP.net MVC
body: <p>I am saving image files in a folder /images/profile and i want to save the image path in a database and do not know how to display image in a view. I am new to MVC. Following are the codes for image uploading. Please help.</p>
  
  <p>HomeController.cs</p>
  
  <pre><code>public class HomeController : Controller
      {
  
          ImageEntities db = new ImageEntities();
          public ActionResult Index()
          {
              return View();
          }
  
          public ActionResult FileUpload(HttpPostedFileBase file, tbl_Image model)
          {
              if (file != null)
              {
                  string pic = System.IO.Path.GetFileName(file.FileName);
                  string path = System.IO.Path.Combine(
                                         Server.MapPath("~/images/profile"), pic);
                  // file is uploaded
                  file.SaveAs(path);
  
              }
  
      return View("FileUploaded", db.tbl_Image.ToList());
  
          }
  
          public ActionResult FileUploaded()
          {
              return View();
          }
  
      }
  </code></pre>
  
  <p>FileUpload.cshtml</p>
  
  <pre><code>@using (Html.BeginForm("FileUpload", "Home", FormMethod.Post, 
                              new { enctype = "multipart/form-data" }))
  {  
      &lt;label for="file"&gt;Upload Image:&lt;/label&gt; 
      &lt;input type="file" name="file" id="file" style="width: 100%;" /&gt; 
      &lt;input type="submit" value="Upload" class="submit" /&gt; 
  }
  </code></pre>
  
  <p>FileUploadedView.cshtml</p>
  
  <pre><code>@foreach (var item in Model)
      { 
     &lt;img src="~/images/profile/@item.imagepath" /&gt;
      }
  </code></pre>