I'm using
<img src="@Url.Action("getImage", "AccessFile", new { imagePath= @ViewData["imagePath"] })"/>
in the View to display image that exists as a local file in the server.
getImage action in AccessFileController will look like
public ActionResult getImage(string imagePath)
{
if (!System.IO.File.Exists(imagePath))
{
//Log
return ?????????
}
else
{
return base.File(imagePath, "image/jpg");
}
}
My question is, what should I put in ????????? to allow user to see some kind of error message?
I tried
- return new HttpNotFoundResult();
- return RedirectToAction("ExpectedError", "Error");
but it only returns empty image with a broken icon on it.
Any good solution?