MS Chart not rendering on MVC 2 with .NET 4

2

November 17, 2010 by temebele

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>


Advertisements

2 thoughts on “MS Chart not rendering on MVC 2 with .NET 4

  1. Elaine Purse says:

    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.

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: