how to download file in c#?
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>
Share This with your friend by choosing any social account