0

i'm trying to display an image in my view.

i've written an Image helper:

    public static class Helpers
    {
        public static FileContentResult Image(this HtmlHelper htmlHelper, 
        byte[] imageData, string mimeType)
        {
            return new FileContentResult(imageData, mimeType);
        }
    }

myImage - is a byte array.

<img src="@Html.Image(myImage, "image/jpeg")" />

but my image is not displayed...

when i look at the source code all i see is:

<img src="System.Web.Mvc.FileContentResult">

anyone? :)

1

1 Answer 1

0

The way you are doing it you are returning the FileContentResult in between the quotes of the src="".

I see what you are trying to do, but in order for this to work, the <img src=> needs to request the URL of the image not simply put the byte[] in the src. So you'll need to set up an action method that takes in some parameter and returns the FileContentResult.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.