In this tutorial, I am going to explain how to display image from a byte array in ASP.NET MVC using C# .NET and VB.NET.
C#.NET Code
VB.NET Code
Now, let me explain what is there in the code.
Now, add a new View to GetImageFromByteArray action method. And, add an image view. We can directly assign the image data from ViewBag to src attribute of the image tag like below.
Output
Now, if you run the program, you can see the output of how to display the image from the byte array. Now, if you look into the source of the page, you can see the base 64 string rendered as an image.
Conclusion
I hope you learned how to display the image f the om byte array in MVC. Please post your comments and feedback below.
Hands on with ASP.Net MVC - Covering MVC 6