Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Charting Control not working on production server

I have an application that relies heavily on charting and currently the charts will work in the ASP.Net Development Server, but when I try to publish out to my server (Win 2008 Server R2, IIS 7), the charts do not show up.

Using Firebug, I can see that the call to ChartImg.axd returns a 404, and all I get is a blank image holder in IE, or nothing in Firefox. I've searched for about 3 or 4 hours so far, and have tried just about everything recommended, but nothing seems to be working.

I would like to use memory/HttpImageHandler, instead of the ImageLocation configuration.

My Web.Config

    <appSettings>
    <!--<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />-->
    <add key="ChartImageHandler" value="storage=memory;timeout=20;deleteAfterServicing=false" />
  </appSettings>
  <system.webServer>
    <handlers>
      <remove name="ChartImageHandler" />
      <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
        path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>
  </system.webServer>
  <system.web>
    <httpHandlers>
      <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        validate="false" />
    </httpHandlers>
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
          assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </controls>
    </pages>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </assemblies>
    </compilation>
    <customErrors mode="Off"/>
  </system.web>

Does anyone have any ideas where I'm going wrong to keep this from working on my server?

like image 816
Adam Avatar asked Oct 28 '11 19:10

Adam


2 Answers

I found the answer to my problem, but I believe that my problem stemmed specifically from how my code runs.

Once I set privateImages=false under appSettings for my ChartImageHandler, my images came up with no problem, using ImageLocation with file storage or HttpHandler with memory storage.

I looked at the listing here and realized that my code has NONE of the following:

  • Authentication
  • SessionID
  • AnonymousID

so the implicit default setting of privateImages=true was keeping me from downloading my images. When I set privateImages=false I had no problems and the charts worked correctly. I set my application to use Windows Authentication, and set privateImages=true and my charts are now being generated with either the Image Location setting or the HttpHandler setting.

Hopefully this is helpful. I know I spent a long time digging around and got nowhere.

like image 191
Adam Avatar answered Oct 25 '22 22:10

Adam


This configuration work for me. You need to use memory as storage.

< add key="ChartImageHandler" value="storage=memory;deleteAfterServicing=true;timeout=20;"/>
like image 31
Kyaw Nyi Win Avatar answered Oct 25 '22 23:10

Kyaw Nyi Win