我希望能在FileContentResult结果方法中返回一张“默认图像”,而不是null。基本上,我在项目的许多视图中调用下面的方法。但问题是,当该方法无法检索到图像时会返回null,并导致调用它的每个页面出现错误。如果没有检索到图像,则要使用保存在项目中的图像进行显示。我不想在数据库中保存默认图像。任何帮助将不胜感激...
[AllowAnonymous]
public FileContentResult GetLogoImage()
{
var logo = _adminPractice.GetAll().FirstOrDefault();
if (logo != null)
{
return new FileContentResult(logo.PracticeLogo, "image/jpeg");
}
else
{
return null;
}
}