8

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?

Adam
  • 808
  • 6
  • 13
  • 23

6 Answers6

6

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.

Adam
  • 808
  • 6
  • 13
  • 23
2

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

< add key="ChartImageHandler" value="storage=memory;deleteAfterServicing=true;timeout=20;"/>
Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115
  • I realize this is a bit of an old post, but can you tell me where exactly you inserted the above line of code? Thx. – htm11h Oct 02 '12 at 20:45
  • In the App.Config file in the section – Dave Lucre Oct 09 '13 at 23:16
  • I think this is the real answer. The problem appears to be that if you leave the storage with its default value ("file"), then the handler tries to create a file and serve it out to the client. If the user does not have authorization to create files on the server location specified in that char image handler app setting, then the whole thing fails. But what we probably want is for the server to create the image in memory and feed it out to the client from there. No need to create a physical file that gets into file authorization issues. –  Apr 12 '17 at 20:53
1

It seems like security/permission issue. Are you saving charts to local folder, then assign write permission for IIS user and/or network services users for that folder.

dpac
  • 145
  • 4
  • 12
  • Although I'm trying to not use Image Location, I did give Network Service modify permissions for my c:\TempImageFiles\ folder, and the images do get placed in the folder, which leads me to believe that it works as intended, but they are not coming forward to my application. I still seem to get a 404 error when doing this. – Adam Oct 28 '11 at 20:03
  • Try creating 'tempimagefile' folder under your IIS folder and try accessing it directly from web like 'www.yourdomain.com/Tempimagefile/char.jpg' and see if it works. Then use this location in your webpage. – dpac Oct 28 '11 at 21:42
  • Or, change the ChartImageHandler specs in the app settings to create the image in memory rather than in a file. –  Apr 12 '17 at 20:55
0
  <controls>
        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
          assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </controls>

try this: change Version=4.0.0.0 to Version=3.5.0.0

shakizat
  • 11
  • 1
0

try this it was resolved in case of web.config runtime error

<pre>
<add key="ChartImageHandler" value="storage=memory;timeout=20;deleteAfterServicing=true;Url=~\temp\"

/>

0

Install the Microsoft Chart Controls on your webserver or try this:

ASP.Net Chart Control On Shared Hosting Environment

Also check that the HttpHandler is registered in system.webServer in your web.config when running under IIS 7.

JamieSee
  • 12,696
  • 2
  • 31
  • 47
  • I believe Chart Controls are built in to the .NET 4.0 Framework. The Handler is present in the Listings for the application under Handler Mappings in IIS Manager – Adam Oct 28 '11 at 20:02