开发者

thumbnail does not open the image in Mozilla and google chrome

Hello everyone I hope I get a reply to this question...I have grid view and one of the fields in e table is a template field w开发者_如何学运维ith a hyperlink and this hyperlink is basically a thumbnail image...when the user clicks on this thumbnail image the full image opens up in another window. This works fine forme in IE but when I open up the site in mozilla or chrome...I don't get the full image...I get some random numbers and alphabet...so not sure why this is happening only in Mozilla and chrome...Is there any additional line of codes that I need to add for these 2 browsers. Can anyone suggest an idea or a piece of code that wld help me in resolving the issue?.thank u once again everyone and hope to see someone help me out of this...if anything else let me know...thank u


Its appears from your code that you are not setting the content type for the response. In absense of content type, browsers may treat it as generic binary content, hence the issue. The issue would have been applicable for thumbnail but in that case, you have set it as source to image - hence browser knows that the binary data is in some image format. Browsers such as google chrome issues warning in such cases saying that the data is binary but it is inferring it as image.

The solution is simple - set the content type explicitly:

Response.ContentType = "image/jpeg";

You may also consider setting content disposition in case of full images such as

Response.AppendHeader("content-disposition", "inline; filename=" + fileName);

From performance perspective, you should consider un-buffered response while sending images. Further, you can also have jpeg file on disk and transfer it directly such as

...
    Response.TransmitFile(filePath);
}

In such case, ASP.NET runtime handles file transfer to IIS which knows how to stream files to client.

In case of thumbnails, you should consider caching of generated thumbnails to avoid re-generating them again and again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜