locked
Error executing child request for ChartImg.axd RRS feed

  • Question

  • I am trying to get started with the ASP.net chart controls and I keep getting the error message "Error executing child request for ChartImg.axd"

    I've dumbed it down to a cut and paste sample from the samples site. I checked and made sure that the DLL is installed, referenced, etc. 
    Also made sure that the user that VS/WebDev.WebServer runs as (me) has rights to the TempImages folder.

    Anyone had any luck with this and have any suggestions?

    Thanks!





    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ChartTest._Default" %> 
     
    <%@ Register Assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
        Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head runat="server"
        <title></title
    </head> 
    <body> 
        <form id="form1" runat="server"
        <div> 
         
        <asp:ScriptManager runat="server" ID="ScriptManger1" /> 
         
            <asp:chart id="Chart1" runat="server" Height="296px" Width="412px" ImageLocation="~/TempImages/ChartPic_#SEQ(300,3)" Palette="BrightPastel" imagetype="Png" BorderDashStyle="Solid" BackSecondaryColor="White" BackGradientStyle="TopBottom" BorderWidth="2" backcolor="#D3DFF0" BorderColor="26, 59, 105"
                            <legends> 
                                <asp:Legend IsTextAutoFit="False" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold"></asp:Legend> 
                            </legends> 
                            <borderskin skinstyle="Emboss"></borderskin> 
                            <series> 
                                <asp:Series Name="Column" BorderColor="180, 26, 59, 105"
                                    <points> 
                                        <asp:DataPoint YValues="45" /> 
                                        <asp:DataPoint YValues="34" /> 
                                        <asp:DataPoint YValues="67" /> 
                                        <asp:DataPoint YValues="31" /> 
                                        <asp:DataPoint YValues="27" /> 
                                        <asp:DataPoint YValues="87" /> 
                                        <asp:DataPoint YValues="45" /> 
                                        <asp:DataPoint YValues="32" /> 
                                    </points> 
                                </asp:Series> 
                            </series> 
                            <chartareas> 
                                <asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" BackSecondaryColor="White" BackColor="64, 165, 191, 228" ShadowColor="Transparent" BackGradientStyle="TopBottom"
                                    <area3dstyle Rotation="10" perspective="10" Inclination="15" IsRightAngleAxes="False" wallwidth="0" IsClustered="False"></area3dstyle> 
                                    <axisy linecolor="64, 64, 64, 64"
                                        <labelstyle font="Trebuchet MS, 8.25pt, style=Bold" /> 
                                        <majorgrid linecolor="64, 64, 64, 64" /> 
                                    </axisy> 
                                    <axisx linecolor="64, 64, 64, 64"
                                        <labelstyle font="Trebuchet MS, 8.25pt, style=Bold" /> 
                                        <majorgrid linecolor="64, 64, 64, 64" /> 
                                    </axisx> 
                                </asp:ChartArea> 
                            </chartareas> 
                        </asp:chart> 
        </div> 
        </form> 
    </body> 
    </html> 
     
     


    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.DataVisualization.Charting; 
     
    namespace ChartTest 
        public partial class _Default : System.Web.UI.Page 
        { 
            protected void Page_Load(object sender, EventArgs e) 
            { 
                // Create new data series and set it's visual attributes 
                Series series = new Series("Spline"); 
                series.ChartType = SeriesChartType.Spline; 
                series.BorderWidth = 3
                series.ShadowOffset = 2
     
                // Populate new series with data 
                series.Points.AddY(67); 
                series.Points.AddY(57); 
                series.Points.AddY(83); 
                series.Points.AddY(23); 
                series.Points.AddY(70); 
                series.Points.AddY(60); 
                series.Points.AddY(90); 
                series.Points.AddY(20); 
     
                // Add series into the chart's series collection 
                Chart1.Series.Add(series); 
     
     
            } 
        } 
     
     

    Wednesday, October 29, 2008 5:29 PM

Answers

  • I encountered the "Error executing child request" error on my page as well and followed all the instructions in this thread but no luck. So I used Reflector to see what was going on, found the Server.Execute mentioned earlier in this thread and then debugged into the .NET source code to see what was going wrong and I think I've found the cause of my error.

    As mentioned everywhere you have to add the following handler to the configuration of your web app:

     <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

    In my case the chart is on the second tab of a Telerik RadMultiPage which uses postbacks. When I open the second tab the chart is loaded and the Server.Execute to ChartImg.axd is called. When you use Server.Execute, the http verb used for the parent request is also used for the child request. Since I'm doing a postback the verb will be POST which -as you can see in the "verb" attribute in the configuration setting above- is not allowed so it throws an error. So the simple change you have to make to get the chart to work is to add "POST" to the allowed verbs:

     <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

    This would also explain why the chart control won't work on anything but the first page of an asp:wizard control or any other page where the EnsureInitialized check is done in a postback.

    I've seen this error message on many forums without a satisfactory fix being offered, so I'm guessing it's pretty common. As far as I can tell, the Server.Execute call to ChartImg.axd is only done to ensure the handler is configured correctly. It's kind of ironic that this check is the cause of so many errors. I think it's a case of code trying to be too smart for it's own good.
    Monday, January 12, 2009 10:39 AM
  • DrNelsona:

    If you want to use Chart.ImageLocation you also have to set 

    Chart1.ImageStorageMode = System.Web.UI.DataVisualization.Charting.
    ImageStorageMode.UseImageLocation;
    This will bypass chart image handler but you will lose privacy,multi-worker process and web farms handling.

    Take a look at this post how to run the chart under ASP.Net MVC:
    http://code-inside.de/blog-in/2008/11/27/howto-use-the-new-aspnet-chart-controls-with-aspnet-mvc/
    Friday, December 5, 2008 7:01 PM
    Moderator

All replies

  • It looks like there is an issue in chart HTTP handler configuration. You can try use image location instead, by setting Chart.ImageStorageMode="UseImageLocation".

    If you want to verify your HTTP handler, open your web.config file and make sure you have all chart related settings in there. All these settings should be automatically added when you add a chart from the toolbox into your web page.

    ...
    <
    appSettings>
        
    <
    add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
    </
    appSettings>

    <httpHandlers>
    ...
        <add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
    ...
    </
    httpHandlers>

    <handlers>
    ...
        <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

    ...
    </
    handlers>



    Alex.

     

    Wednesday, October 29, 2008 8:08 PM
  • Those settings were missing from the web config (I used the toolbox the first time I tried in my real project, but in my test project I copy/pasted the code from the sample.)

    I verified that both changing ImageStorageMode or adding the specified items to Web.config resolve the issue.

    Thanks! :)

    Hopefully this gets indexed and people searching for that error can find it; MSChart is so new that I couldn't find any reference to that error :)
    Wednesday, October 29, 2008 9:09 PM
  • I was also having this problem!  I added those values to the web.config and bam!... problem gone!
    Tuesday, November 4, 2008 2:46 PM
  • Hmm...these settings were already in my web.config and recopying them from here didn't fix the problem.  Setting the ImageStorageMode="UseImageLocation" works but I cannot get the HTTP handler to work.  Any other ideas?
    Tuesday, November 18, 2008 7:25 AM
  • What kind of error message you getting?
    Tuesday, November 18, 2008 8:48 AM
  • Hey Alex,

    First of all thanks for the fix. I pulled the chart from my toolbox and it still didn't automatically populate the web.config file. I'll continue to look into that. I did have another question. Is there anyway you can show me an example of the application settings and httphander settings you would use for making the chart use session variables to store the image? I am limited in that I can't do any file i/o on the servers.

    Just making sure I'm not missing anything as I'm having a hard time tracking images being created at all in the c:\TempImageFiles\.

    Any help would be appreciated,
    Nick


    Tuesday, November 18, 2008 4:43 PM
  • Alex-

    I am getting the same error as the original poster described:

    "Error executing child request for ChartImg.axd"

    Thanks for any other suggestions.
    Tuesday, November 18, 2008 5:05 PM
  • Settings in the webconfig usually the source of any HTTP Handler issues. Have you installed the samples and do they work fine? If samples run fine, what is the difference between your weconfig and the one in the samples. Also try creating a brand new ASP.NET application drop a chart in there and see if it works.

    Alex.
    Tuesday, November 18, 2008 6:03 PM
  • This is strange...the samples work, and also if I create a new project and add a chart it works.  It is only in my project that it doesn't work.  I tried copying all of the sections from the sample project's web.config into mine but it still doesn't work.  Could there be something conflicting in my web.config?  Here it is:

    <?xml version="1.0"?><configuration> 
          
      <configSections> 
            <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">  
                <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">  
                    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>  
                    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">  
                        <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>  
                        <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>  
                        <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>  
                        <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>  
            </sectionGroup> 
          </sectionGroup> 
        </sectionGroup> 
      </configSections> 
     
      <appSettings> 
        <add key="ChartImageHandler" value="Storage=file;Timeout=20;Url=~/tempImages/;"/>  
      </appSettings> 
          
      <connectionStrings> 
            <add name="websiteConnectionString" connectionString="" providerName="System.Data.SqlClient"/>  
            <add name="appservicesdbConnectionString" connectionString="" providerName="System.Data.SqlClient"/>  
        </connectionStrings> 
          
      <system.web> 
            <sessionState cookieless="AutoDetect">  
            </sessionState> 
              
        <compilation debug="true">  
                <assemblies> 
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>  
            <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>  
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>  
            <add assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
            <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>  
          </assemblies> 
        </compilation> 
              
        <authentication mode="Forms">  
                <forms loginUrl="~\MembershipFiles\LoginPage.aspx" cookieless="AutoDetect"/>  
            </authentication>         
     
        <customErrors mode="Off"/>  
              
        <pages theme="defaultTheme">  
          <controls> 
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
            <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
            <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>  
          </controls> 
        </pages> 
              
        <membership defaultProvider="CustomizedProvider">  
                <providers> 
                    <clear/> 
                    <add name="CustomizedProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="appservicesdbConnectionString" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" requiresUniqueEmail="true" applicationName="/"/>  
                </providers> 
            </membership> 
          
            <roleManager enabled="true" defaultProvider="CustomizedRoleProvider">  
                <providers> 
                    <clear/> 
                    <add name="CustomizedRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="appservicesdbConnectionString" applicationName="/"/>  
                </providers> 
            </roleManager> 
              
        <healthMonitoring enabled="true">  
                <providers> 
                    <clear/> 
                    <add name="SqlWebEventProvider" connectionStringName="appservicesdbConnectionString" maxEventDetailsLength="1073741823" buffer="false" bufferMode="Notification" type="System.Web.Management.SqlWebEventProvider"/>  
                </providers> 
                <rules> 
                    <clear/> 
                    <add name="Failure Audits Events Rule" eventName="Failure Audits" provider="SqlWebEventProvider" profile="Critical"/>  
                </rules> 
            </healthMonitoring> 
              
        <trace enabled="true" mostRecent="true"/>  
              
        <deviceFilters> 
                <filter name="IsIEBrowser" compare="Browser" argument="IE"/>  
            </deviceFilters> 
     
        <httpHandlers> 
          <remove verb="*" path="*.asmx"/>  
          <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
          <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
          <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>  
          <add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>  
        </httpHandlers> 
              
        <httpModules> 
                <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
        </httpModules> 
      </system.web> 
        
      <system.net> 
            <mailSettings> 
                <smtp from="">  
                    <network host="PLCNU8300MLT" password="" userName=""/>  
                </smtp> 
            </mailSettings> 
        </system.net> 
     
      <location path="Admin">  
        <system.web> 
          <authorization> 
            <deny users="?"/>  
          </authorization> 
        </system.web> 
      </location> 
     
      <location path="User">  
        <system.web> 
          <authorization> 
            <deny users="?"/>  
          </authorization> 
        </system.web> 
      </location> 
        
        <system.codedom> 
            <compilers> 
                <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4" compilerOptions="/warnaserror-">  
                    <providerOption name="CompilerVersion" value="v3.5"/>  
          </compiler> 
                <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" compilerOptions="/optioninfer+">  
                    <providerOption name="CompilerVersion" value="v3.5"/>  
          </compiler> 
        </compilers> 
      </system.codedom> 
          
     
      <!--  
            The system.webServer section is required for running ASP.NET AJAX under Internet  
            Information Services 7.0. It is not necessary for previous version of IIS.  
        --> 
        <system.webServer> 
         <validation validateIntegratedModeConfiguration="false" /> 
        <modules> 
          <remove name="ScriptModule"/>  
          <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
        </modules> 
        <handlers> 
          <remove name="WebServiceHandlerFactory-Integrated"/>  
          <remove name="ScriptHandlerFactory"/>  
          <remove name="ScriptHandlerFactoryAppServices"/>  
          <remove name="ScriptResource"/>  
          <remove name="ChartImageHandler"/>  
          <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
          <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
          <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>  
          <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>  
        </handlers> 
     </system.webServer> 
     
    </configuration> 

    Thanks for your help
    Tuesday, November 18, 2008 11:52 PM
  • Just an observation, not necessarly an answer. 

    I had the previously-described symptom ("Error executing child request for ChartImg.axd") - until I realized I had targeted the 2.0 Framework in my build options.  As soon as I switched to 3.5 all was well. 

    This does not seem to explain MDMoore resolving this issue by adding the code Alex provides.  However, it has been observed that Framework 2.0 will actually run the Chart Controls (http://forums.microsoft.com/MSDN/ShowPost.aspx?Post&Site)

    As for the code not being automatically added to web.config:
    I had that symptom also.  But, upon switching the target Framework, VS found the Chart control and the missing code was "retroactively" added to web.config.  Nice.

    For readers who haven't done this:
    Right-click your project, select Start Options, select Build, etc.

    ...Late entry...
    Regarding the ChartImageHandler key in appSettings:
    The auto-generated code in my project set this as follows:

    <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" /> 

    This was fine with the ASP.NET Development Server, but not when I published the project to IIS (even IIS on the local machine).  Running the published project produced:

    Invalid temp directory in chart handler configuration [c:\TempImageFiles\].

    Using Process Monitor (http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx) I could see aspnet_wp.exe looking for this png file first in the root of my published webfolder.  Then, not finding it there it looked for the folder c:\TempImageFiles\ - which never did exist on this PC.

    Completly removing the dir attribute of the ChartImageHandler value solved the problem.  But, perhaps not in the best way.  Perhaps someone else will explain further.

    NOTE: ChartImg.axd is queried for in your published webfolder also.
    Thursday, November 20, 2008 7:44 AM
  • Well I still don't know why I was getting the exception but I seem to have found a workaround.  I did an experiment where I took the supposed offending web.config and copied it to a new project where I added a new web form and chart control and the chart control rendered fine with the "UseHttpHandler" option.  This led me to believe that it wasn't actually the web.config that was the problem in my case, so I went back to the original project and added a chart to another web form as an experiment, and it worked!  Even more surprising was that after that I went to the offending page and it worked too!  Then I took the new chart off the other page and checked the original offending page and it was broken again.  Then I found out if I put a chart control on any page before the offending page, it would work, otherwise it threw the exception.  These controls are so cool though that I didn't have a problem finding another page to put one on in the path of the offending page :)

    This fixed the problem but if anyone has any theory why I'd be interested...maybe a bug?
    Friday, November 21, 2008 7:03 AM
  • I can confirm andersco's findings, the workaround I made (When using the ChartImageHandler) was to add the line

    <asp:chart id="Chart2" runat="server" Height="1px" Width="1px"></asp:chart> 


    to the bottom of the page leaving all other settings as they are.

    My page contains one other chart control "Chart1" that uses UseHttpHandler ImageStoreageMode - visiting any page within the project with a chart control on it before viewing this page means everything works fine, viewing the page with the UseHttpHandler chart image first causes the ChartImg.axd error.
    Wednesday, November 26, 2008 1:05 PM
  • my english is poor

    my soluction:

        <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />

    To
        <add key="ChartImageHandler" value="storage=file;timeout=20;" />

    OK

    Thursday, November 27, 2008 6:07 AM
  • Hello to everybody,
    I'm also get stucked on ChartImageHandler's problem.... I debugged a bit using reflector and MS Symbols and I found that the EnsureInitialized method executes :

    private static void EnsureInitialized(bool hardCheck)
    {
    if (!_installChecked)
    {
    if (HttpContext.Current != null)
    {
    try
    {
    HttpContext.Current.Server.Execute("ChartImg.axd");
    _installed = true;
    }
    catch (HttpException)
    {
    if (hardCheck)
    {
    throw;
    }
    }
    catch (SecurityException)
    {
    _installed = !string.IsNullOrEmpty(WebConfigurationManager.AppSettings["ChartImageHandler"]);
    }
    }
    _installChecked = true;
    }
    if ((_installed || hardCheck) && (_parameters == null))
    {
    _parameters = InitializeParameters();
    InitializeControllerFile();
    }
    }

    I get this inside the StaticFileHandler.cs :

    private static FileInfo GetFileInfo(string virtualPathWithPathInfo, string physicalPath, HttpResponse response) {
    // Check whether the file exists
    if (!FileUtil.FileExists(physicalPath)) {
    throw new HttpException(HttpStatus.NotFound,
    SR.GetString(SR.File_does_not_exist));
    }
    // To prevent the trailing dot problem, error out all file names with trailing dot.
    if (physicalPath[physicalPath.Length-1] == '.') {
    throw new HttpException(HttpStatus.NotFound,
    SR.GetString(SR.File_does_not_exist));
    }
    }

    and it's related to the file "ChartImg.axd", is it possible that for some reason the axd file is not been created?
    It's looking for it into website bin directory..is it ok?
    Thanks



    Monday, December 1, 2008 4:25 PM
  • I've been getting this error as well and I found that it happens when I have a chart control set to display:none and later displays itself after a postback.  When I changed it to a visibility:hidden so that it's still rendering just not displaying it worked fine.  Luckily our current site design allowed this kind of change.  It looks like there's something that the chart control doesn't like about only being displayed after postbacks.
    Monday, December 1, 2008 9:35 PM
  • I am also getting this error, when trying to use the charts within an ASP.Net MVC application.

    I have tried all of the suggestions so far but still no joy. The code I am running is as follows:
            Chart PRReport = new Chart(); 
            PRReport.Width = 412
            PRReport.Height = 296
            PRReport.RenderType = RenderType.ImageTag; 
            PRReport.ImageLocation = "..\\..\\TempImages\\ChartPic_#SEQ(200,30)"
     
            PRReport.Palette = ChartColorPalette.BrightPastel; 
            Title t = new Title("Problem Records Report", Docking.Top, new System.Drawing.Font("Trebuchet MS", 14, System.Drawing.FontStyle.Bold), System.Drawing.Color.FromArgb(26, 59, 105)); 
            PRReport.Titles.Add(t); 
            PRReport.ChartAreas.Add("Series 1"); 
     
            // create a couple of series 
            PRReport.Series.Add("Series 1"); 
     
            CustomLabel myLabel; 
            int i = 1
     
            // add points to series 1 
            foreach (Report pr in (IEnumerable)ViewData["PRReport"]) 
            { 
                if (pr.Count > 0) 
                { 
                    myLabel = PRReport.ChartAreas["Series 1"].AxisX.CustomLabels.Add((Convert.ToDouble(i) - 0.5), (Convert.ToDouble(i) + 0.5), pr.Name); 
                    PRReport.Series["Series 1"].Points.AddY(pr.Count); 
                    i++; 
                } 
            } 
     
            PRReport.BorderSkin.SkinStyle = BorderSkinStyle.Emboss; 
            PRReport.BorderColor = System.Drawing.Color.FromArgb(26, 59, 105); 
            PRReport.BorderlineDashStyle = ChartDashStyle.Solid; 
            PRReport.BorderWidth = 2
     
            // Render chart control 
            PRReport.Page = this
            HtmlTextWriter writer = new HtmlTextWriter(Page.Response.Output); 
            PRReport.RenderControl(writer); 
     

    The web.config contains all the pieces mentioned so far in this discussion...


    Friday, December 5, 2008 9:07 AM
  • If you have problems with chart handler, try changing the "starage" from "file" to "memory" or "session".

    <add key=“ChartImageHandler” value=“storage=memory;timeout=20;”/>

    or:

    <add key=“ChartImageHandler” value=“storage=session;timeout=20;”/> 

    • Proposed as answer by sm300 Friday, February 4, 2011 11:13 PM
    Friday, December 5, 2008 5:55 PM
  • DrNelsona:

    If you want to use Chart.ImageLocation you also have to set 

    Chart1.ImageStorageMode = System.Web.UI.DataVisualization.Charting.
    ImageStorageMode.UseImageLocation;
    This will bypass chart image handler but you will lose privacy,multi-worker process and web farms handling.

    Take a look at this post how to run the chart under ASP.Net MVC:
    http://code-inside.de/blog-in/2008/11/27/howto-use-the-new-aspnet-chart-controls-with-aspnet-mvc/
    Friday, December 5, 2008 7:01 PM
    Moderator
  • I was getting this same error on my development and our QA 64-bit environments.  When setting the ImageStorageMode= property, it output the .png file but did not listen to the URL=~/TempImageFiles/ and put it in the root of the directory.  I experimented with the storage=memory but that didn't do anything.  I ended up thinking about just removing the setting and lo, it creates the image in memory of the machine. 

    Once I deployed to my QA environment, everything seems to be much happier without that property. 

    New problem: I'm using Windows Load Balancing for this site and it appears that the image will render on that one machine; Looking into what ever caching is needed.
    Monday, December 8, 2008 4:51 PM
  • hello, anyone else is experiencing this error on vista/windows 2008 64bit edition?
    I've tried all the possible solution explained in this thread (and in other similar) but the only way I got it working is using "UseImageLocation"...
    I've found (enabling native code debugging) that it hangs here (inside httpserverutility.cs):

       public void Execute(string path) {
                Execute(path, null, true /*preserveForm*/);
            }

    with path set as "ChartImg.axd", is it rigth??

    Thanks in advance
    Paolo

    Wednesday, December 10, 2008 10:11 AM
  • Hello,
    I've discovered what causes the iussue..... We've got a logged content page under the path ~/ControlPanel/Statistics.ascx, we load this usercontrol from an asp:Menu and the ascx is loaded inside a ContentPlaceHolder.
    Here's the code of the aspx :

    Code

    If I load before a page that load a chart and it's "simplier" then this one I'm able to load also this ascxwithout any problem, otherwise I get this error "Error executing child request for ChartImg.axd" . If I reset the application pool I've to redo the trick...
    Is it possible that it's due to partial page rendering?
    Thanks in advance
    Paolo

    Thursday, December 11, 2008 1:49 PM
  • I don't know if this is the same problem as everyone else has seen (sounds like maybe it's different).

    I wrote a page with a chart in it.

    I then changed the page to use an asp:Wizard - the chart being in the last step.

    After this change, I got the executing error shown below when I reached the last page.

    Moving the chart out of the wizard and back into the root of my control removed the error.

    However, when I moved the chart back to the last step of the wizard again, the error was cleared....

    Somewhat confused at present...


    Error executing child request for ChartImg.axd.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Error executing child request for ChartImg.axd.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): Error executing child request for ChartImg.axd.]
    System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +2675871
    System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm) +819
    System.Web.HttpServerUtility.Execute(String path) +8
    System.Web.UI.DataVisualization.Charting.ChartHttpHandler.EnsureInitialized(Boolean hardCheck) +152
    System.Web.UI.DataVisualization.Charting.ChartHttpHandler.EnsureInstalled() +27
    System.Web.UI.DataVisualization.Charting.Chart.GetImageStorageMode() +46
    System.Web.UI.DataVisualization.Charting.Chart.Render(HtmlTextWriter writer) +201
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
    System.Web.UI.Control.Render(HtmlTextWriter writer) +10
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27


    Stuart
    Tuesday, December 16, 2008 11:51 AM
  • Just as a follow up to that last post

    Have it reproducible.

    - If I restart the webserver each time (I'm using the dev web server at present) with the chart inside the wizard then I get the error - until I move the chart outside the wizard.

    - If I restart the webserver with the chart outside the wizard then it works, then when I move the chart inside the wizard again, then it still works.

    (Not sure it's relevant, but in this current app my page contains a user control in which I've placed the wizard inside the last step of which I've placed another custom control inside which I've placed the chart)

    Stuart - geekie blog at http://slodge.blogspot.com
    Tuesday, December 16, 2008 12:05 PM
  • I encountered the "Error executing child request" error on my page as well and followed all the instructions in this thread but no luck. So I used Reflector to see what was going on, found the Server.Execute mentioned earlier in this thread and then debugged into the .NET source code to see what was going wrong and I think I've found the cause of my error.

    As mentioned everywhere you have to add the following handler to the configuration of your web app:

     <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

    In my case the chart is on the second tab of a Telerik RadMultiPage which uses postbacks. When I open the second tab the chart is loaded and the Server.Execute to ChartImg.axd is called. When you use Server.Execute, the http verb used for the parent request is also used for the child request. Since I'm doing a postback the verb will be POST which -as you can see in the "verb" attribute in the configuration setting above- is not allowed so it throws an error. So the simple change you have to make to get the chart to work is to add "POST" to the allowed verbs:

     <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

    This would also explain why the chart control won't work on anything but the first page of an asp:wizard control or any other page where the EnsureInitialized check is done in a postback.

    I've seen this error message on many forums without a satisfactory fix being offered, so I'm guessing it's pretty common. As far as I can tell, the Server.Execute call to ChartImg.axd is only done to ensure the handler is configured correctly. It's kind of ironic that this check is the cause of so many errors. I think it's a case of code trying to be too smart for it's own good.
    Monday, January 12, 2009 10:39 AM
  • charts were working fine, until I added a series in the design time that wouldn't render.
    I tried to undo my changes, to no avail.

    For some reason my tempImages dir had been set to read-only (nb a square tick - so guessing sub files),
    unchecking this solved the problem for me.

    I am running vs2008 sp1 on 64 bit vista, if it helps. With the same web.config relevant to charting as the samples.

    The only unusual tihng I have is I have enabled all verbs (GET POST PUT etc) for ashx files, incase this help the MS team debug things.

    Thursday, February 12, 2009 5:22 PM
  • Matt M19543 said:

    I've been getting this error as well and I found that it happens when I have a chart control set to display:none and later displays itself after a postback.  When I changed it to a visibility:hidden so that it's still rendering just not displaying it worked fine.  Luckily our current site design allowed this kind of change.  It looks like there's something that the chart control doesn't like about only being displayed after postbacks.



    I'm essential getting the same thing however I leave all my charts Visible="false"  and add a visible="true", empty chart and the exception isnt raised. Strange but true...



    Thursday, February 19, 2009 1:45 PM
  • Set Chart's properties (in design view), ImageStorageMode to UseImageLocation just works like charm for me.

    • Proposed as answer by bharatB Wednesday, December 15, 2010 1:37 AM
    Thursday, March 5, 2009 4:06 AM
  • I tried editing the web config too with each person's suggestions, but no luck. Changing the ImageStorageMode (in design mode) to 'UseImageLocation' as just suggested fixed it for me. I had also dragged and dropped the original control onto my page and had it working great, tweaking whatever I wanted in the properties. I think it broke (as another user sugggested), when I then tried to programatically create a chart. After this I couldnt get working again until changing ImageStorageMode. Thanks for the great tip; WE ALL WIN!  :)

    -Rick
    Thursday, March 5, 2009 6:14 PM
  • I am also facing problem on rendering the images on a load balancer. Any help would be appreciated.

    Thursday, March 12, 2009 11:14 PM
  • thanks, this works
    Monday, May 11, 2009 8:23 PM
  • If anyone still having problems, you can modify httpHandlers to something like this on your web.config.

    <

     

    add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

     

     

    validate="false" />

    Monday, May 11, 2009 8:33 PM
  • I had the same problem but thx for your post, its really helpful and I did well
    thx.
    Friday, May 15, 2009 9:38 AM
  • Thank Ng. Your tip works great.

    dcpt
    Friday, May 15, 2009 8:38 PM
  • P.Looijmans solution worked for me...I had the chart controls in an update panel and was calling __doPostBack(UpdatePanelClientID, '') to trigger a refresh...Actually I added POST to both the HttpHander and the Handler, but that's probably just through ignorance :) .   
    Wednesday, May 27, 2009 4:48 AM
  • I gave NETWORK SERVICE write permissions to the site directory and it works.  My key="ChartImageHandler" is set to "storage=file;timeout=20;".
    Tuesday, June 2, 2009 10:16 AM
  • After setting this  <add key="ChartImageHandler" value="storage=file;timeout=20;" />

    i got this error: System.UnauthorizedAccessException: Access to the path 'C:\Inetpub\vhosts\login.supertec.com\httpdocs\ChartPic_000002.png' is denied.
    Monday, June 8, 2009 5:17 AM
  • its working fine now, just give all permisions to root folder. Thanks

    • Proposed as answer by siplaModerator Tuesday, August 9, 2011 8:55 AM
    • Unproposed as answer by siplaModerator Tuesday, August 9, 2011 8:55 AM
    Monday, June 8, 2009 6:52 AM
  • thanks for the help....... after changing in the web.config, it's worked for me
    Monday, October 12, 2009 6:32 AM
  • Thanks, this helped me solve the issue i was experiencing
    Friday, October 30, 2009 1:51 PM
  • Oh my word, this is terrible advice.

    I could understand setting up a particular folder for reading/writing these images expressly for the benefit of cacheing them, but to give all-perms to the root folder of the website is just asking to get harmed in all sorts of foul ways.

    Please, never enable write access on folders which don't need it.

    Security 101.
    Please don't forget (and feel free to remind me) to post if you got the answer you wanted, and select who really answered your post when you do so future visitors will know too! Remember, this is .NET 4.0 in a .NET 3.5 world, you're a pioneer right now.
    Friday, October 30, 2009 4:11 PM
  • Hi, I got the same error when i first used it. Try adding a chart control to the designer rather than the mark up. This adds the necessary entries on to the web.config and the issue gets resolved. Thanks, -SandeepT
    Thursday, December 31, 2009 6:59 PM
  • This was exactly what I needed thanks

    Wednesday, January 6, 2010 9:41 PM
  • did you try to set the path to a shared network drive? essentially all web apps will pull & store to the same location this way.

    Alex Talarico
    Saturday, January 23, 2010 2:34 AM
  • I changed the setting in my config file based on the recommendations suggested here and still did not work. The one thing I did notice I did not have a tempimages folder in my project. I added that and everything works.

    Just a suggestion...

    Tuesday, February 23, 2010 5:05 PM
  • Hi,

    thanks a lot this helped me a lot. What i was missing is adding an key to handlers attribute in SP2010 where as in MOSS 2007 this is not required. thanks a lot for this great post


    Regards, Amar.
    Monday, June 21, 2010 6:22 AM
  • I think i am missing some so simple.

    I have made the changes to the web.config as suggested, but it still gave me the error.

    Are there any prerequisites to this that maybe i am missing? I read something about charts... do i need charts installed?

    Thank you in advance

     

    Friday, August 13, 2010 9:03 PM
  • @Jvanblu: can you explain with more info?

    • Proposed as answer by bharatB Wednesday, December 15, 2010 1:52 AM
    Wednesday, October 27, 2010 4:30 PM
  • This issue can be resolved with combining couple of things alltogether:

    adding the following property to Chart as suggested by Yee:

     

    ImageStorageMode="UseImageLocation"

    Change the web config, replace the code with the following if exists already:

    <

     

    add key="ChartImageHandler" value="Storage=file;Timeout=20;Url=~/tempImages/;"/>

    <

     

    add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />

    Make sure, you have proper rights on the folder  "tempimages"  under the application path or any other folder specified where chart is going to store the temp files. I gave "Everyone" user group full rights to this folder which works fine for me.

     

    • Proposed as answer by subho100 Tuesday, August 9, 2011 10:21 AM
    Wednesday, December 15, 2010 1:53 AM
  • Bom senhores,

     

    Apesar do tempo do último post... uma das soluções que encontrei foi, além de criar a pasta foi dar permissão para o ASPNET utilizar a mesma.

     

    e só!

     

     

    Monday, February 21, 2011 1:43 PM
  • I finally got your example above working with VS2010 using all the various online help sources.  Your example above is quite attractive.  Thx
    Tuesday, May 3, 2011 2:50 PM
  • I added POST to the HANDLERS and the HTTPHANDLERS and then I had to recycle the website (shut it down and start it again) for it to take.
    Monday, August 8, 2011 9:01 PM
  • Thanks Looijmans - this was very helpful.  I'd like to add that I had to change the version number to Version=4.0.0.0 when applying the code.  To get the right version number select the dll (reference) in Visual Studio and check it properties.  Ruchir

    Friday, October 25, 2013 10:49 AM
  • Thank you Alex.  Just adding that in the <appSettings> where the file path has spaces then an &quot seemed to help eg,  

    dir=&quot;C:\01 Folder 1\&quot;;"/>


    Friday, October 25, 2013 10:55 AM