Reputation: 4919
Below is the output of the fancybox iframe from google chrome
And Here is the output of the fancybox ifrom from IE
Here is the Markup page code:
<script type="text/javascript">
$(document).ready(function () {
/*
* Examples - images
*/
$("[id*=img]").fancybox();
$('.fancyframe').fancybox({
'titlePosition': 'inside',
'type': 'iframe',
'width': 1024,
'height': 768
});
});
</script>
<a class="fancyframe" href="/imgLoader.aspx"><img src="/imgLoader.aspx"></a>
Here is the code behind of imgLoader.aspx
protected void Page_Load(object sender, EventArgs e)
{
byte[] a = Common.GetImage();
Response.BinaryWrite(a);
}
Why chrome only loads the byte array instead of the image while IE can display the image and how to fix this bug?
Upvotes: 0
Views: 578
Reputation: 23796
Because you are just sending down a byte array and aren't telling the browser what it is.
protected void Page_Load(object sender, EventArgs e)
{
byte[] a = Common.GetImage();
Response.BinaryWrite(a);
}
Try adding:
Response.ContentType = "image/jpeg";
Before you call Response.BinaryWrite
Edit: FYI, I usually also call Response.Clear()
before writing out the image, and then Response.End
after.
So:
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
byte[] a = Common.GetImage();
Response.BinaryWrite(a);
Response.End();
}
Why? Just to make sure ASP.NET doesn't have any other junk it's sending down to the browser that might confuse it.
Upvotes: 1