Last post Feb 14, 2012 11:42 AM by bbcompent1
Feb 13, 2012 08:09 PM|kvh|LINK
Thumnail image is returned via handler. First time all is OK. but when I do refresh, then istead of image is displayd some machine code in Firefox.
I traced to root cause with Fiddler, it is because first time Content-Type comes correctly image/png
but with refresh it is coming as text/html. what should be added, that after refresh browser still could get image/png? below is my code
Bitmap target = new Bitmap(width, height);
context.Response.ContentType = "image/png";
using (Graphics graphics = Graphics.FromImage(target))
graphics.CompositingQuality = CompositingQuality.HighSpeed;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.DrawImage(photo, 0, 0, width, height);
HttpCachePolicy cachePolicy = context.Response.Cache;
cachePolicy.VaryByParams["car_image_id"] = true;
cachePolicy.SetExpires(DateTime.Now + TimeSpan.FromDays(365));
using (MemoryStream memoryStream = new MemoryStream())
using (FileStream diskCacheStream = new FileStream(cachePath, FileMode.CreateNew))
Feb 13, 2012 08:22 PM|bbcompent1|LINK
I'm thinking you might need to have some of this inside a (!PageIsPostBack) because the second time the pages loads I doubt it is a full postback.
Feb 13, 2012 10:54 PM|kvh|LINK
this is HttpHandler and only thing here is "ProcessRequest". I tried adding Postback check, but got error "IsPostback does not exist in the current context".
Feb 14, 2012 11:42 AM|bbcompent1|LINK
To get access to it, you have to do something like HTTPContext.Current or something like that.