0

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.

versus
  • 95
  • 6
  • Is this image dynamically loaded (from a database or other source) or is it static on disk? – JP. May 01 '12 at 14:11
  • image is dynamically loaded into Image instance field when ImageConstructor is called. So file contents already exist in View Model and returning it as a result of some action of controller (as many approaches offer) is not good.. – versus May 01 '12 at 16:45

0 Answers0