Asp.net mvc 在Aviary编辑器中加载作为FileContentResult返回的图像
我目前在一个MVC项目中工作,我目前的要求是在Aviary图片编辑器中加载图像。我遇到的问题是,我使用输入类型“file”选择的图像使用FileContentResult呈现到视图中,我想在Aviary editor中加载此选择的图像 在视图上渲染选定图像的图像标记如下所示Asp.net mvc 在Aviary编辑器中加载作为FileContentResult返回的图像,asp.net-mvc,aviary,filecontentresult,Asp.net Mvc,Aviary,Filecontentresult,我目前在一个MVC项目中工作,我目前的要求是在Aviary图片编辑器中加载图像。我遇到的问题是,我使用输入类型“file”选择的图像使用FileContentResult呈现到视图中,我想在Aviary editor中加载此选择的图像 在视图上渲染选定图像的图像标记如下所示 <img id="imgTest" src="<%: Url.Content("~/[Controller]/[Action]/?a=" + Model.a + "&b=" + Model.b + "&a
<img id="imgTest" src="<%: Url.Content("~/[Controller]/[Action]/?a=" + Model.a + "&b=" + Model.b + "&c=" + Model.c) %>" alt="example" />
“alt=”示例“/>
我将获取图像的id和src以在aviary中启动它,但由于这是作为操作结果返回的FileContentResult,因此它不会在编辑器中加载,并且我不确定如何从中获取真实图像。如何在aviary中加载该图像?您可以定义一个返回FileContentResult的操作,如:
public FileContentResult getImage(int id)
{
byte[] byteArray = DbContext.Persons.Find(id).Image;
if (byteArray != null)
{
return new FileContentResult(byteArray, "image/jpeg");
}
else
{
return null;
}
}
剃刀
<img src="@Html.Action("getImage", "Person", new { id = item.Id })" alt="Person Image" />