Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 在MVC4视图中显示字节数组图像_Image_Asp.net Mvc 4_Html Helper - Fatal编程技术网

Image 在MVC4视图中显示字节数组图像

Image 在MVC4视图中显示字节数组图像,image,asp.net-mvc-4,html-helper,Image,Asp.net Mvc 4,Html Helper,我正在尝试在视图中显示图像 我已经编写了一个图像助手: public static class Helpers { public static FileContentResult Image(this HtmlHelper htmlHelper, byte[] imageData, string mimeType) { return new FileContentResult(imageData, mime

我正在尝试在视图中显示图像

我已经编写了一个图像助手:

    public static class Helpers
    {
        public static FileContentResult Image(this HtmlHelper htmlHelper, 
        byte[] imageData, string mimeType)
        {
            return new FileContentResult(imageData, mimeType);
        }
    }
myImage-是一个字节数组

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

但是我的图像没有显示

当我看源代码时,我看到的是:

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


有人吗?:)

您这样做是在
src=”“
的引号之间返回
FileContentResult


我知道你想做什么,但是为了让它工作,
需要请求图像的URL,而不是简单地将
字节[]
放在src中。因此,您需要设置一个操作方法,该方法接受一些参数并返回
FileContentResult

请查看此问题的答案