Home > .NET 4, ASP.NET 4, ASP.NET MVC 2 > MS Chart not rendering on MVC 2 with .NET 4

MS Chart not rendering on MVC 2 with .NET 4

If you have been using ASP.NET 3.5 Charts, when upgrading to .NET 4 you will ran in to issues with the image source path for ChartImage.axd.

Make sure you add the following to your Global.asax.cs Application_Start.

RouteTable.Routes.Ignore(“{*pathInfo}”,new { pathInfo =@”^.*(ChartImg.axd)$” });
AreaRegistration.RegisterAllAreas();
RegisterRoutes(
RouteTable.Routes);

Note: the ignore route for ChartImage.axd needs to be before any area registration.

Technorati Tags: ,


Web.Config Changes:

<assemblies>
<
add assembly=System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35/>
</
assemblies>
<controls>
<
add tagPrefix=asp namespace=System.Web.UI.DataVisualization.Charting assembly=System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 />
</controls>
<
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>
<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>


Advertisement
  1. June 3, 2011 at 6:25 pm | #1

    Thank you so much for this! I was trying to create a chart in a partial view by passing through a chart object as described in http://www.codecapers.com/post/Build-a-Dashboard-With-Microsoft-Chart-Controls.aspx and was getting very frustrated at getting an image not found symbol instead of the chart until I found your post.

    • June 6, 2011 at 2:49 am | #2

      I am glad that helped. I shared it because I also ran into the same problem once.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.