How can I make a controller method called
GetMyImage()
ActionResult
string
Return FilePathResult using File method of controller
public ActionResult GetMyImage(string ImageID)
{
// Construct absolute image path
var imagePath = "whatever";
return base.File(imagePath, "image/jpg");
}
There are several overloads of File method. Use whatever is most appropriate for your situation. For example if you wanted to send Content-Disposition header so that the user gets the SaveAs dialog instead of seeing the image in the browser you would pass in the third parameter string fileDownloadName
.