我使用返回错误信息/为FileResult页在ASP.NET MVC
<img src="@Url.Action("getImage", "AccessFile", new { imagePath= @ViewData["imagePath"] })"/>
在视图中显示存在作为服务器的本地文件的图像。在AccessFileController
的getImage动作看起来就像
public ActionResult getImage(string imagePath)
{
if (!System.IO.File.Exists(imagePath))
{
//Log
return ?????????
}
else
{
return base.File(imagePath, "image/jpg");
}
}
我的问题是,我应该把在?????????允许用户看到某种错误信息?
我试图
- 回报新HttpNotFoundResult();
- return RedirectToAction(“ExpectedError”,“Error”);
但它只返回空图像与它的一个破碎的图标。
任何好的解决方案?
这不是一个fileresult,该解决方案行动结果不会为行动结果 –