I have been playing around with the ASP.NET 4.0 Chart Controls for a new web site (Bilvärdet.se – used car price statistics)
When deploying it to IIS7 on my Windows Server 2008 I ran in to a few problems:

1) I did not have .NET 4.0 Framework installed on the server

🙂 It turns out .NET 4.0 Framework is an optional update in Windows Update and for some reason that I could not figure out failed to install (error code: 80200053) Solution that worked: Manually installed it. I had to use a tool that was new to me, the Microsoft Web Platform Installer (Web PI). Seems to be a cool tool to download, install and configure all sorts of software (incl WordPress, Dupral, Joomla) on Windows, will check this out in more detail in the future.
Don’t forget to change the Application Pool for your Web Site/Web Application in IIS Manager to use .NET Framework 4.0

2) Next problem, error message: An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode

This turned out to be a few lines of code in web.config that seems to be needed on my development machine (Windows7 and Visual Studio 2010) but causes problems on IIS7.
Just removed this section from production web.config on server and it worked:
1
2
3
4
5
6
<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>
Thanks to Michael Narinsky for pointing this out.

3) Image file directory problems

First error message: Invalid temp directory in chart handler configuration c:\TempImageFiles\
Solution: Changed dir in ChartImageHandler app settings in web.config
1
2
3
<appSettings>
     <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;"/>
</appSettings>
Then this error message: The temp directory in chart handler configuration is not accessible c:\xxx\images\
Followed error message suggestion and added access rights to directory (Properties – Security tab) for user NETWORK SERVICE
[Update: Other error message that can appear:
a) “Access to the path ‘C:\xxx\images\charts\chart.png’ is denied.” – this is the same as above, add rights for NETWORK SERVICE
b) “Could not find a part of the path ‘C:\xxx\images\charts\chart.png’.” – make sure directory exists or create it]

4) Charts not rendering with ASP.NET Routing

I’m using ASP.NET 4.0 Routing but this seems to be something Charts are not working well with. Charts are showing up as broken links. If you are using routing, you need to make sure ChartImg.axd is ignored. Add Ignore (or IgnoreRoute) and – this took me quite some time to figure out – make sure you add these before any MapPageRoute or it will not work!
This is what I added in VB.NET, add one line per level in virtual/route folder structure – first line is for root, second line for one subdirectory level, third line for two subdirectory levels.
1
2
3
routes.Ignore("ChartImg.axd/{*pathInfo}")
routes.Ignore("{controller}/ChartImg.axd/{*pathInfo}")
routes.Ignore("{controller}/{action}/ChartImg.axd/{*pathInfo}")

F