📜  公共 FileStreamResult RenderImage(int id) { MemoryStream ms = null ; var item = db.Products.FirstOrDefault(p => p.ProductID == id); if (item != null) { ms = new MemoryStream(item.Image); } 返回新的 FileStreamResult(ms, item.ImageType); } 代码示例

📅  最后修改于: 2022-03-11 14:56:59.205000             🧑  作者: Mango

代码示例1
public FileStreamResult RenderImage(int id)
        {
            MemoryStream ms = null ;

            var item = db.Products.FirstOrDefault(p => p.ProductID == id);
            if (item != null)
            {
                ms = new MemoryStream(item.Image);
            }
            return new FileStreamResult(ms, item.ImageType);
        }