Convert Byte Array to image and display in Razor View

There’s an even easier way of doing this if you already happen to have the image loaded in your model:

<img src="data:image;base64,@System.Convert.ToBase64String(Model.Image)" />

Doing this way you do not need to go to the server again just to fetch the image byte[] from the database as you’re doing.

Leave a Comment