how to download file in c#?

  By Zaif Ullah   Posted on November-26-2018   663

.Net

  public FileResult Download(int id)
        {
                var filename = string.Empty;
                var model = db.Cracks.Find(id);
                filename = model.CracksImage;
                string url = HttpContext.Server.MapPath("~/" + AppConstants.RecipesImages+"/"+ filename);
                byte[] fileBytes = System.IO.File.ReadAllBytes(url);
                return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, filename);
            
          } 


 <div class=" col-md-offset-7">
                                     <a href="~/BrowseCracks/Download/@item.CracksId"> <button class="btn btn-primary">Download </button></a>
                                 </div>

By  zaifullah489-000001    26-Nov-2018 Views  663



You may also read following recent Post

Item Image
What are 3 C
 228
Item Image
what is .net
 462
Submit Post - Article - Ask a Question - Ask an Interview Question - Submit Useful Links