Believing this as an answer here to provide help to others, such as myself, who were looking for how to display web images, and came through this SO publication in the search results of the 3 best search engines. This also seems to be a better answer than the Java servlet issuing images in the response.
FireFox does not display network images, so I created an MVC helper that extends HtmlHelper.
public static class ImageHelper
{
public static MvcHtmlString PhotoBase64ImgSrc(this HtmlHelper html, string fileNameandPath)
{
var byteArray = File.ReadAllBytes(fileNameandPath);
var base64 = Convert.ToBase64String(byteArray);
return MvcHtmlString.Create(String.Format("data:image/gif;base64,{0}", base64));
}
}
use in MVC View like this:
using
<img src="@Html.PhotoBase64ImgSrc(image)" height="60px" width="60px" alt="photo" />
here the "image" in @ Html.PhotoBase64ImgSrc (image) is a clean UNC network, for example.
source
share