title: ASP.Net - Multiple dynamic images. Performance issues due to too many Http Requests
body: <p>I use an HttpHandler to dynamically serve images in a ASP.Net web application.
  I am having a performance issue (Firfox/Firebug/YSlow reports there are too many HttpRequests)</p>
  
  <p>I have between 50-100 images per page in some instances.. 3 treeviews (business units/categories/objects) with each node having its own image ;)</p>
  
  <p>Each item's image url is set dynamically like so...</p>
  
  <p>SomeImage.ImageUrl = "/image.axd?ImageId={0}";</p>
  
  <p>Note: I only know at runtime which images will be required. </p>
  
  <p>Additional: Images are located on the server file system, in a resource file and also in the database - users can upload their own images to associate with my system objects and the ImageHandler will determine each image location dynamically)</p>
  
  <p>In the web.config the httphandler is configured and works as expected...
  add verb="GET" path="image.axd" type="Vision.OnsightManager.ImageHandler"</p>
  
  <p>In the HttpHandler the raw image bytes are returned in response to each image request.
  So in the WriteResponse() method of the image handler the image bytes are returned, like so...</p>
  
  <p>context.Response.BinaryWrite(bytes);</p>
  
  <p>All images display correctly, but the app has performance problems as expected where many images are displayed...</p>
  
  <p>Question:</p>
  
  <p>What approach do you recommend, apart from reducing image count ;), for minimizing all the HttpRequests generated for each image? Maybe combining into a single Http request?</p>
  
  <p>I have read articles on combining multiple css requests into a single request, using image mapping (single combined image with offsets) etc, but none seem to suit my particular scenario?</p>
  
  <p>Much obliged!</p>