如何从字节显示图像

本文关键字:显示图 图像 显示 字节 | 更新日期: 2023-09-27 18:28:45

错误

编译器错误消息:CS1502:最合适的方法重载'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)"包含一些无效的参数

 @ImageResultHelper.Image<ShowcaseController>(c => c.FileContentResult(), 200, 50, "Current time")

并且我需要将新的{字节=item.ImageItems}传输到FileContentResult

如何从字节显示图像

我们的方法是返回FileContentResult:

public FileResult Get()
{
    return new FileContentResult(image.Bytes, image.ContentType);
}

然后我们将图像的src设置为以下操作:

<img src="/Controller/Get/" alt="Whatever" />

通过这种方式,您可以缓存结果。