asp.net - IHttpHandler for images producing a stackoverflow in IE -


I have a directory of images located outside the context of my web application which I need to serve the user I currently I'm using IHttpHandler to serve images and using some javascript to navigate through a set of images (navigation is now primitive). I use the examples IHttpHandler uses to illustrate the images closely, but when I look at the images in Firefox hanging in the browser and when I look in IE, I get the "Stack overflow line: 0" < / p>

IHttpHandler code

  public class ShowImage: (ByVal context as HttpContext) Implements IHttpHandler public sub ProcessRequest _ Implements IHttpHandler.ProcessRequest picid be as dim string Contekstkrikvest. QueryString ( "ID") nothing isnot again picid = context.Request.QueryString ( "ID") or else throw new ArgumentException ( "no parameter specified") End If '' [] bitmap bytes context.Response.Cache.SetCacheability convert (HttpCacheability.NoCache) context.Response.Cache.SetNoStore () context.Response.Cache.SetExpires (DateTime.MinValue) nothing dim newBmp bitmap = If newBmp isnot GetPhoto (as picid) graphics = Graphics.FromImage Again the dim imgGraphics (newBmp) ImgGraphics.DrawImageUnscaled (newBmp, 0, 0, 640, 480) reference. response. Status code = 200 references. Response. Contact type = "i mage / jpeg" newBmp.Save (context.Response.OutputStream, ImageFormat.Jpeg) newBmp.Dispose () or 'return 404 context.Response.StatusCode = 404 context.Response.End () End If End Sub ... Public ReadOnly property's IsReusable () Get _ Implements IHttpHandler.IsReusable as Boolean return must really termination property end class  

JavaScript code above here IHttpHandler Call Is doing:

  function update image () {var ddlPhotos = document.getElementById ("ddlPhotos"); Var selected = ddl photo. Option [ddl.photo.selectedIndex] .value; (If selected! = -1)} function retrievePicture (imgCtrl, picid) {imgCtrl.src {// image retrievePicture (document.getElementById (selected "propertyImage"),) updated} = 'ShowImage.ashx? Id = '+ picid; }  

Finally here is the IIG tag which is the "Place Holder":

   

I understand why Javascript is running out of control ...

My guess - is not a Javascript expert - it is that whenever the image is loaded onload event is triggered at any time. In other words, as soon as the image is full, it starts a new loading ... which loads a new load ... which is loading a new etc.

You might be able to see that in multiple calls to the server for the same image - as long as the browser is not caching it, of course. Anyway, you will either need to trigger it in some other way, or find the trigger that the image that is loaded is already correct, and there is no need to change it.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -