Search code examples
c#html.netasp.net-mvcasp.net-mvc-5

Display Bitmap in Image Control


I am developing ASP.NET MVC 5 application. I need to display Bitmap image from controller in HTML tag <img />. How can I do it?

Please read: this question is not "too broad". It specifically asks how to show Bitmap C# object in HTML image tag using ASP.NET MVC. Please reopen it.


Solution

  • You can simply use something like following

    <img src="@String.Format("data:image/png;base64,{0}", Convert.ToBase64String(Model.imageBytes))" />