title: ASP.NET MVC download image rather than display in browser
body: <p>Rather than displaying a PNG in the browser window, I'd like the action result to trigger the file download dialogue box (you know the open, save as, etc).  I can get this to work with the code below using an unknown content type, but the user then has to type in .png at the end of the file name.  How can I accomplish this behavior without forcing the user to type in the file extension?</p>
  
  <pre><code>    public ActionResult DownloadAdTemplate(string pathCode)
      {
          var imgPath = Server.MapPath(service.GetTemplatePath(pathCode));
          return base.File(imgPath, "application/unknown");
      }
  </code></pre>
  
  <h3>Solution....</h3>
  
  <pre><code>    public ActionResult DownloadAdTemplate(string pathCode)
      {
          var imgPath = Server.MapPath(service.GetTemplatePath(pathCode));
          Response.AddHeader("Content-Disposition", "attachment;filename=DealerAdTemplate.png");
          Response.WriteFile(imgPath);
          Response.End();
          return null;
      }
  </code></pre>