我的项目中有数据;它是Base64格式图像。 当我在Visual Studio中运行它时,我的 img src:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAE8SURBVDhPnZKxSgQxEIZj4wl7IKIIWlxhZSe+gCAIdtqIiorVIWhjZ3FY2VqJguALaCFYWPsGIl5tZ2npAzj+X0ziXnZvEX/4IJudfzIziavVdGdudLV72urdvbSvX62J4EgqWgfn92OHF491wXUEnzQx02lfPn+xufLwZlf9D3t6//SwZi83Q3C7AvPkTd8HDxP/iKkkoGw+kvl206w3Mgh7EjGDCTQweqZEr9yYI5XbcUybRVPpucpVuHhVDMvOxs2OndlRoCt2xbpYEgti1vnYlCAufIIdBWyLfbEntsSaWBaLYl5M/Sbg8JTgPy3QfkqQhshJTUjEMnguICWAVMXJRtXInhRP5+r9Gygn+PND0qOTtagkiFAiwQwLWKe7x6xn780oNw+DnkPZPydH1QWX4ar8tBlYRc59A7oPZwm6y2RfAAAAAElFTkSuQmCC">
但是当它在IIS中发布时,字符串太长而图像不透明:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAXUSURBVEhLjdYJTFN3HAfwxzFPRLcmOEWMMWMqMjaviDMjc9NYDwQWdRpRCIJT3Ok2EDe3IYcRdIZDOYQpOCyCMq+4Oa+o45BDqEyhXG2BlvuQYoG+vv93v9eC11jmL/n0NT3+3/fv+/9/fdx/lCUZYX7Kjfbx8fHV6XT6gYEBI8/zTISXrMExni97e/spqVRFWj2iCzux4WITZqbWY2qSCpMS1JiYpMaUFDUcjqlgn1hrdrQa9vEVsI/9Gw4x5Tj7oH3YACsvL6+1LVQlzX1YmKbkZ6TUCnNSa9jm8xq281o7Aq91wE3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5SfkcD18h3E7fhNqqGgLWJsDwkrxKq1pq4gytD02QN2lh4aWnYaW3bCGeU/d0YvIPyuYRWA2ez/upuDo6DhL3GTmgH0lsI2WY0yUHMWt/fQzaIDgVcAP7kDISrPdJJgEkW/ILvLVCuBzKS2IDwBtBSbt/QOcfwafV9s61EVHmANCqUlFlZIy2B+WQ9FBrflOFoxv0PqmtW1a528TF+JMnMhss376DHKOor5Tx7gt6cbdF+4JYuOkwS2IpTlgby5sI2mLRxaZWq51WBHGhBVAJ775MBeIDIBx4SvgKUDEVjgA328Ciq/gaKGWSfZcBudzShjgjQgKCgoxnftQmQK+uw3biHzq5dQNw6lZUdjYiEI4x5bgUEkXKmlCaFUCtUVADenrhZpaSkJpG+P8ZYzbLuODz8kRHByyZ3BY05+XqcQAy5AbmBD2F2xF1AlF4ylsVGguuJCbkITegndONb6+1miyKCaXjQk6zzifTGHZkdu4XtkM+lnaBod8OrhYYsDJ4kbTP9Dzmk1kpmMTsqm3iM7Ktaho7kFXj86gUCiqnJ2dXQaHGr7EgJepodsVcftnU3l4eHgODiGWeIsj3uq8UBz3Dxg48SVTmAD6AAAAAElFTkSuQmCC">
用于将位图图像转换为base64我使用方法:
using (MemoryStream ms = new MemoryStream())
{
img.Save(ms, ImageFormat.Png);
byte[] imageBytes = ms.ToArray();
return string.Format("data:image/png;base64,{0}",Convert.ToBase64String(imageBytes));
}
有什么不对吗?