我想要显示一张图片,但我有这样的HTML(基本64字符串为了简洁而被截断)
<p><img alt="downloadjpg" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxQTEhUSEhMVFRQWFxUWFxQVFxgUFBcVFRQWFxQVFxYYHCggGBolHBUVITEhJSkrLi4uFx8zODMsNygtLisBCgoKDg0OGxAQGywkICQsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLP/AABEIALEBHAMBEQACEQEDEQH/xAAbAAACAwEBAQAAAAAAAAAAAAAEBQIDBgEAB//EAEIQAAEDAgUBBgMGBAQEr6U/uvtJbpI4/Zf41f7jQH730kyvDeYeyf1rknGRxfPvRL39oPaG4ryI/A3/ALjUnoJJ6Spnf4/Sl/1QTK8Z5vhQL96EesHwvkX/AHzT1+/Ii9zemSJ//9k=" title="downloadjpg" class="img-responsive">aaaaaaaaaaaaa</p>
我将HTML放在标签中:
@Html.LabelFor(m => m.EmailBody, Model.EmailBody)
图像未显示。我做错了什么?
答案 0 :(得分:1)
错误是:您的base64图片代码错误请再次检查
如何在浏览器中测试,复制src和过去 使用此链接对图像进行编码Encode image based64
尝试使用此代码
<div>
<p>Taken from wikpedia</p>
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />
</div>
或
@Html.RAW(Model.EmailBody)