asp.net display image from byte array

前端 未结 3 1735
不思量自难忘°
不思量自难忘° 2020-12-31 18:18

I have a byte array and trying to display image from that.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.W         


        
3条回答
  •  无人及你
    2020-12-31 19:02

    Another way to do it is to convert your byte array into a base 64 string and assign that to the ImageUrl property of rImage, like so:

    rImage.ImageUrl = "data:image;base64," + Convert.ToBase64String(arr);
    

    You don't need the intermediate MemoryStream or a separate page...if the byte array is in an image format the browser supports, it will display. Good luck.

提交回复
热议问题