Search code examples
c#asp.netwebformsmicrosoft-chart-controls

ASP.NET 4.0 Chart Control Broken Image Link


I have Microsoft Chart Controls set up in a Web Forms project. The chart is rendering as a broken image link. The page I'm attempting to add the chart control is in a location with this path:

http://localhost/application/default.aspx

The broken image link being generated is:

http://localhost/Application/ChartImg.axd?i=chart_14e94045c8ec4bd1b79f8ad4a6e25239_0.png&g=10889d08b1644464955d275d1f800315

If I manually change the broken image link to the following, it renders:

http://localhost/ChartImg.axd?i=chart_14e94045c8ec4bd1b79f8ad4a6e25239_0.png&g=10889d08b1644464955d275d1f800315

Web.config:

<add name="ChartImg" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />;

<add key="ChartImg" value="Storage=memory;Timeout=20;"/>

(Also tried <add key="ChartImg" value="storage=file;timeout=20;dir=c:\TempImageFiles\;"/ >)

UPDATE

It's the actual location of the ChartImg.axd handler that is causing the problem. I think the page inheritance and namespaces are messed up in this huge legacy project. I'm trying to add the chart to a page in the /Application directory - I need to be able to change path to the handler. Anyone?


Solution

  • I was able to solve this by creating a new page in the project root with the same master page, and then using an iframe in the problematic page to bring in the charts. I could find no other way to programmatically change the "virtual" location of the ChartImg.axd handler itself.

    <iframe src="../Metrics.aspx" height="400" width="400" frameborder="0"></iframe>