ASP.NET 4.0 Chart Control breaks IIS 7.0

I’ve decided to add the new ASP.NET 4.0 Chart Control to one of my web apps. Everything worked fine during the testing on my local machine, but once I published it to remote IIS 7.0 server I’ve got the following error:

HTTP Error 500.23 - Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

Turns out that it occurs because ASP.NET modules and handlers should be specified in the IIS <handlers> and <modules> configuration sections in Integrated mode.

So the simple solution that worked for me was just to remove the following entry from web.config <system.web> section:

<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>

Also make sure that <system.webServer> section has the following:

<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>

15 comments:

Max said...

Thanks for the info! I blogged about this and some other gotchas with the chart controls and iis7.

BR Max

Anonymous said...

Thnx m8! This was the post I needed the most. Lost a day on it... really thnx a lot!
John,
Belgium...

Jhony Moncada said...

Great post! It solved my problem in IIS 7.0. Thank you for sharing the solution!

Loky said...

Thank you so much !!!! It solved my problem on IIS 7.0

skemuel007 said...

Thanks so much for the post,
followed instruction as stated above and created the dir=c:\TempImageFiles\; and it worked just fine

All the same thanks.

Anonymous said...

Thanks mate, this really helped me out.

BC

Anonymous said...

Thank You!

The Great Cornholio said...

Oh thank god... this has pissed me off for the last 6 hours, but works now!

Cheers!

Anonymous said...

Still am getting same error

I follow your suggestions but error still present in my server.
Could not load file or assembly 'System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Please help me..

Chiefy Williams said...

So am I - still getting the same error, and I've done everything. please help.

Michael Narinsky said...

Are you guys sure you have .NET 4.0 installed?

John Hetzler said...

Thanks for the post!

I solved my issue the same way last night, so today was searching for 'why' it worked and ran across your page. My hosting provider has IIS 7.5 and the 4.5 .NET Framework and I'm using the 4.0 .NET Framework on my local system.

I also found the System.Web.DataVisualization and System.Web.DataVisualization>Design dlls are not needed in the /bin directory.

Is the only section you removed? It was for me. I kept the , , and changes in the web.config file. What did you do with these other sections?

John Hetzler said...

Sorry. I forgot that the section tags are HTML codes and get stripped. Here's the last paragraph corrected:

Is 'httpHandlers' the only section you removed? It was for me. I kept the 'pages', 'assemblies', 'handlers' and 'appSettings' changes in the web.config file. What did you do with these other sections?

Luu said...

thanks for your post. where is the web.config settings for the C:\TempImageFiles

aparna john said...

Hi,This in turn has also pushed many new firms in Web Design Cochin to join the business of developing websites for their clients making competition tougher than before. To live up in this competitive market place, it is very essential for you to know the basic facts before choosing a web development.Thanks............