Chart image link broken in load balanced intranet.

Expand / Collapse

Chart image link broken in load balanced intranet.


The chart image links sometimes appear broken in a load balanced intranet environment.


In this scenario, there are 2 http requests - one for the page which generates the image and then the client (browser) makes another for the actual image.  In a load balanced environment the same server which handles the first request may not handle the second.  As a result, the image will only be on one server and if the second request is made to another server the requested image will not be present on that machine.


To circumvent this problem you could wrap the chart class with a class to manage the pathing for different servers.

Note: This solution will only work if each server in the server farm is accessible through http://(MachineName)/


public class ClusterChart: dotnetCHARTING.Chart

     private string imageURL = "";
     public string ImageURL
          get { return imageURL ; }
          set { imageURL = value ; }
     public ClusterChart()
          Random R =new Random();
          string filename = "chart" + R.Next().ToString() + ".png";
          this.TempDirectory = "temp";
          this.FileName = filename;
          this.ImageURL = "http://" + Environment.MachineName.ToLower() + "/temp/" + filename;

     /// <summary>
     /// Renders the chart as an image instead of as a dotnetCHART
     /// </summary>
     protected override void Render(System.Web.UI.HtmlTextWriter writer)
          writer.Write("<img border=0 src=\"{0}\">", this.ImageURL);


Note: The above can be enhanced to use image maps. See sample features/ImageMapText.aspx in the zip file for more information.

Credits: Special thanks to Eric Wood from Charles Schwab for helping develop and test this solution.

Rate this Article:

Add Your Comments

Comment require login or registration.

Last Modified:Wednesday, September 22, 2004
Last Modified By: Support
Type: PRB
Rated 5 stars based on 2 votes.
Article has been viewed 11,681 times.