ASP.NET 4.0 Chart Control Problems on IIS7

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:

[code lang=”xml”]<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> [/code]

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

[code lang=”xml”]<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;"/>
</appSettings> [/code]

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.

[code lang=”vb”]routes.Ignore("ChartImg.axd/{*pathInfo}")
routes.Ignore("{controller}/ChartImg.axd/{*pathInfo}")
routes.Ignore("{controller}/{action}/ChartImg.axd/{*pathInfo}")[/code]

Thanks to Simon Steele.

BTW – Another nice link about ASP.NET Chart Control

12 Replies to “ASP.NET 4.0 Chart Control Problems on IIS7”

  1. The line you removed in the httpHandlers sections isn’t needed at all or it has to be translated in some other way?

  2. Re
    Invalid temp directory in chart handler configuration c:\TempImageFiles\
    Check out the permissions on the User account and ensure these are what you want. Failing which you may get this message no matter what you have put in your web-config file

  3. Thanks for the articule, i was having trouble with error #2, theese are life saving notes when going to production server

  4. Thanks for the info, also where ever you decide to place the .png file gneration process, make sure that in the managed server environment, IIS_IUSER have written permission to create and destroy the .png charts that are created and rendered to the site.
    Also, recommend placing the file in the same file directory tree where the asp.net solution file resides.
    Thanks

  5. OH THANK GOD!! This was driving me INSANE. I cound’t for the life of me figure out why a webform would render a chart correctly in the root but not in a sub/subdirectory.

    That said, i’d not just limit the excludes to the chartimg.axd

    here’s what i wound up with that works beautifullly

    routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”)
    routes.Ignore(“{controller}/{resource}.axd/{*pathInfo}”)
    routes.Ignore(“{controller}/{action}/{resource}.axd/{*pathInfo}”)

    and just for good measure:
    routes.IgnoreRoute(“{resource}.aspx/{*pathInfo}”)
    routes.Ignore(“{controller}/{action}/{resource}.aspx/{*pathInfo}”)
    routes.Ignore(“{controller}/{resource}.aspx/{*pathInfo}”)

Leave a Reply

Your email address will not be published. Required fields are marked *