public async Task <FileContentResult> Thumbnail(int id) { RepositoryProducts repo = new RepositoryProducts(); ProductPhoto productPhoto = await Task.Run(() => repo.GetPhoto(id)); if (productPhoto == null) { return(null); } int fileExtPos = productPhoto.LargePhotoFileName.LastIndexOf("."); if (fileExtPos <= 0) { return(null); } string contentType = string.Format("image/{0}", productPhoto.LargePhotoFileName.Substring(fileExtPos + 1, productPhoto.LargePhotoFileName.Length - fileExtPos - 1)); return(File(productPhoto.ThumbNailPhoto, contentType)); }