我使用返回錯誤信息/爲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,該解決方案行動結果不會爲行動結果 –