Rendering image in a View

China☆狼群 提交于 2019-12-12 01:45:45

问题


I'm trying to show some picture for user in a strongly typed View.. In Model members there is one that represents contents of image (ex. jpeg) How should I pass this content to img tag to render this image? model looks like:

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

View looks like

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

and I render it from parent View as:

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

I've searched a lot, but found only implementations of returning image as a result of action of some controller..Is there any way to show image having fileContentResult in a View? Thanks in advance.

来源:https://stackoverflow.com/questions/10398230/rendering-image-in-a-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!