I've stored an image as a byte array, and now I need to display it back from a byte array.So I have an <img>
tag, and I've assigned the source of that tag at runtime to a method which will fetch the image.
View:
document.getElementById("Logo").setAttribute("src",'@Url.Action("GetImage","AdminLogoManager", new { id = Model.Asset.AssetID})');
<img id="Logo" />
Code in the Controller:
private List<LogoModel> LogoModelList
{
get
{
var logoModelList = GetLogoModelListFromSomewhere();
return logoModelList;
}
}
}
public FileContentResult GetImage(int id)
{
LogoModel m = LogoModelList.Find(p => p.Asset.AssetID == id);
return new FileContentResult(m.Asset.Document, "image/jpeg");
}
But it's not displaying the image. I checked on Chrome debugger, and it says: Server responded with an error of 500 (Internal Server Error) Can anyone help me get this to work?? I know that the LogoModelList is not null or empty, and that the ID is probably correct
PS: It doesn't even debug. I can't set a debug point on GetImage()