Rendering image in a View

2019-08-26 19:36发布

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.

0条回答
登录 后发表回答