title: Image not displaying in ASP.NET MVC
body: <p>In an <code>ASP.NET MVC</code> application, <code>file</code> is successfully saved to a folder and its <code>URL</code> is saved to <code>SQL database</code>. Having problem in loading <code>file</code> in a browser from folder using this <code>URL</code>. Code implementation is: </p>
  
  <pre><code>[HttpPost]
      [ActionName("UploadPhoto")]
      public ActionResult UploadPhoto(HttpPostedFileBase photoPath)
      {
           var fileName = Path.GetFileName(photoPath.FileName);
          string path;
          if (photoPath.ContentLength &gt; 0)
          {
              path = Path.Combine(Server.MapPath("~/Images/photos"), fileName);
              photoPath.SaveAs(path);
          return RedirectToAction("CreateWithImage", new { path = path });
          }
  return View();
      }
  
  public ActionResult CreateWithImage(string path)
      {
          employee em = new employee();
          em.districts = new SelectList(hc.districts, "name", "name");
          em.photoPath = path;
          return View(em);
      }
  </code></pre>
  
  <p>file (image) is rendered in a view as: </p>
  
  <pre><code>@model HRMS.Models.employee
  &lt;dd&gt;
          @Html.Image(@Model.photoPath)
      &lt;/dd&gt;
  </code></pre>
  
  <p>Extension method implementation for <code>@Html.Image</code> is: </p>
  
  <pre><code>    namespace HRMS.CustomeHTMLHelper
  {
      public static class CustomHtmlHelper
      {
          public static IHtmlString Image(this HtmlHelper helper,string src)
          {
              TagBuilder tb = new TagBuilder("img");
              tb.Attributes.Add("src", VirtualPathUtility.ToAbsolute(src));
              return new MvcHtmlString(tb.ToString(TagRenderMode.SelfClosing));
          }
      }
  }
  </code></pre>
  
  <p>When View is called, I see a broken link for the image. HTML(with correct file path) for the loaded page (View) is seen as: </p>
  
  <pre><code>&lt;dd&gt;                
              &lt;img src="/App_Data/photos/1.png" /&gt;
              &lt;/dd&gt;
  </code></pre>
  
  <p>When I try to run the physical path to the image in the browser i.e., <code>&lt;b&gt;Requested URL&lt;/b&gt;    http://localhost:57852/App_Data/photos/1.png</code>, it is throwing <code>HTTP Error 404.8 - Not Found</code> Error. </p>
  
  <p>Where could I be wrong? Please help. </p>