I am trying to return a file (.jpg) that is stored inside the /images folder of my ASP MVC application.
For some reason, the file downloaded is broken/corrupted and none of the photo viewers are recognising the file. I'm certain that the correct file is reachable as the file size is exactly the same and I have specified the contentType in the File() function.
Please can someone help me out? Thanks.
public ActionResult order(int? id)
{
// Logic to get the file path and file name from database
// var ImageName = "file"
// var filepath = will be something like ~/images/file.jpg
byte[] filedata = System.IO.File.ReadAllBytes(filepath);
string contentType = MimeMapping.GetMimeMapping(filepath);
return File(filepath, contentType, ImageName+".jpg");
}