在视图中渲染图像

时间:2012-05-01 13:19:19

标签: asp.net-mvc-3 filecontentresult image-rendering

我正在尝试在强类型视图中为用户显示一些图片。 在模型成员中有一个代表图像内容(例如jpeg) 我应该如何将此内容传递给img标记以呈现此图像? 模型看起来像:

publiс class Image {
public virtual FileContentResult currentImage { get; set; }
public Image()
        {
            currentImage = createSomeImage(); 
// createSomeImage returns new FileContentResult(bmpBytes, "image/png");
        }
}

视图看起来像

@model app.Models.Image
<img src='@Model.currentImage' alt="" class="img" />

我将它从父视图渲染为:

@Html.Partial("_ImageShow", new app.Models.Image())

我搜索了很多,但发现只有一些控制器的操作导致返回图像的实现..有没有办法在视图中显示具有fileContentResult的图像? 提前谢谢。

0 个答案:

没有答案