I have an html with asp C# backend application, where I would like to display a string in the format "data:image/bmp;base64," + base64 encoded string inside an iframe.
The server code is generating the string:
using (MemoryStream stream = new MemoryStream())
{
bitmap.Save(stream, ImageFormat.Bmp);
stream.Position = 0;
content = Convert.ToBase64String(stream.ToArray()); // base64EncodedString
}
and the front-end iframe should display it upon button press:
<form method="POST" runat="server">
<asp:Button runat="server" id="button1" class="btn" Text="Next"/>
<iframe id="iframe" runat="server" class="iframe"></iframe>
</form>
<script>
window.onload = function () {
document.getElementById("<%=iframe.ClientID %>").src="data:image/bmp;base64,"+"<%=content %>";
}
</script>
The content field is populated and shared correctly (as can be displayed in an alert), for example; "data:image/bmp;base64,Qk1aAAAAAAAAAEIAAAAoAAAABgAAAAYAAAABAAQAAAAAAAAAAADEDgAAxA4AAAMAAAADAAAAAAAA/wAA//8A2P//IAEgAAASAAABIAEAEgASACABIAAAEgAA" but the iframe remains blank.
Can you suggest what causes it and how to fix that? thanks!
I have tried using different models of front-back communication including json, ajax,etc. I have also tried to update the iframe src from the asp server side, but as the content variable is correct, I assume the issue is with the front-end.
