I created the basic pie chart and line graph using MS charting. I am developing in .net framework 4.0 so I didn’t install anything related to charting on my computer.
The charts are working properly on my computer when I run it on localhost, but when I deployed the code on windows server they are not working there.
I am not getting any error either otherwise I would have done some research based on the error. The only thing different on the server is the wwwroot directory is on D: drive and .net framework is installed on C: drive.
Also, the System.web.Datavisualization.dll is present on C: drive. Below is my config file for that aspx page
<configuration>
<system.web>
<authorization>
<allow roles="ANALYST"/>
<deny users="*" />
</authorization>
<httpHandlers>
<add path="ChartImg.axd" verb="*" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<add key="ChartImageHandler" value="storage=file;timeout=20;" />
For the charting component you generally need to configure a directory to store the chart in.
For example:
Note the
urlparameter. Also, that directory must be configured to allow your application to write to it.What’s happening is that when you run it locally, the site is executing in the context of your user account. Obviously you have read/write permissions to drop files anywhere within the projects directories. This is why it “works on your machine”.
However, when deployed to the web server it is (most likely) executing under your app pools identity. App pools rarely have the appropriate rights to create files anywhere as that would be a security nightmare.
So, you need to set up a special directory to drop the chart files into. Also you need to make sure the app pool has the appropriate rights to create files in that directory. Finally, you should make damn sure that nothing has rights to execute files in that directory. Otherwise you may as well just zip up your application and data and put a link to that from your home page :/.