image - Charting without using controller action in ASP.NET MVC -
i know how chart using controller action returns fileresult
.
my question is, possible move action view (cshtml) file helper? way view logic entirely contained in view.
the problem is, without controller action, url can fill in img src
attribute? or there different way, instead of img
tag, display image stream?
if core problem want load image data without url (whether url points controller
, or static resource), can dump image data directly html using base64
embedding follows:
public static mvchtmlstring embedimagewithbase64(this htmlhelper helper, byte[] imagebytes) { var base64data = convert.tobase64string(imagebytes); var imagesrcdata = "data:image/png;base64," + base64data; return new mvchtmlstring(string.format("<img alt="chart data" src=\"{1}\" />", imagesrcdata)); }
Comments
Post a Comment