.NET 3.5 图表控件异常:执行 ChartImg.axd 的子请求时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/302820/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.NET 3.5 chart controls exception: Error executing child request for ChartImg.axd
提问by Scott Anderson
Anyone getting this error when using the new free chart controls MS bought from Dundas?
有人在使用从 Dundas 购买的新免费图表控件 MS 时遇到此错误吗?
"Error executing child request for ChartImg.axd"
“执行 ChartImg.axd 的子请求时出错”
On the MSDN forum they suggested it was my web.config: MSDN forum post
在 MSDN 论坛上,他们建议这是我的 web.config: MSDN 论坛帖子
So far that hasn't fixed the problem though. Any other ideas?
到目前为止,这还没有解决问题。还有其他想法吗?
回答by Paul Looijmans
I encountered the same problem: the chart would work on one page but not on the next. Turns out if the chart is initialized for the first time in a POST (i.e. a postback) the error is thrown because the handler is configured incorrectly. To fix the issue modify the httpHandler configuration that user LaptopHeaven referred to in this topic by adding the POST verb:
我遇到了同样的问题:图表可以在一页上工作,但不能在下一页上工作。事实证明,如果图表在 POST(即回发)中第一次初始化,则会抛出错误,因为处理程序配置不正确。要解决此问题,请通过添加 POST 动词来修改用户 LaptopHeaven 在本主题中引用的 httpHandler 配置:
<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" />
I've written a more thorough explanation of why this error occurs in the MSDN forum post that Scott Anderson referred to in his opening post of this topic.
我在 Scott Anderson 在本主题的开篇文章中提到的 MSDN 论坛帖子中编写了更详尽的解释,说明为什么会发生此错误。
回答by LaptopHeaven
I ran into this error, but to correct it by adding an element to the system.web\httpHandler section of my web.config file. I added the follow:
我遇到了这个错误,但通过向我的 web.config 文件的 system.web\httpHandler 部分添加一个元素来纠正它。我添加了以下内容:
<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" />
回答by Sergio
On .NET 4.0 the charts come built-in, but you still may need to add the similar tag below:
在 .NET 4.0 上,图表是内置的,但您可能仍需要添加以下类似的标签:
<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" />
回答by rism
Also note that while dragging the chart control from the toolbox onto your page is supposed to create the necessary entries in web.config, this only occurs if you are in design mode at the time.
另请注意,虽然将图表控件从工具箱拖动到页面上应该会在 web.config 中创建必要的条目,但只有当您当时处于设计模式时才会发生这种情况。
If you are in source mode and drag and drop it will not happen.
如果您处于源模式并拖放,则不会发生。
Also, there must be some form of registration that occurs in the project/class file when you add a chart control in design mode. Because if you are in source mode and dnd a chart control you wont get the entries in web.config as above. If you then step into design mode and dnd from the toolbox into the page, you will get the entries in web.config.
此外,在设计模式下添加图表控件时,项目/类文件中必须存在某种形式的注册。因为如果您处于源模式并且没有图表控件,您将不会像上面那样在 web.config 中获得条目。如果您随后进入设计模式并从工具箱进入页面,您将获得 web.config 中的条目。
But if then delete the chart, you dnd'd in design mode, it will wipe the entries from web.config (assuming a single page site) even though you still have the other chart control on the page from when you dnd'd into source mode.
但是,如果然后删除图表,您就在设计模式下,即使您在页面上仍然拥有其他图表控件,它也会从 web.config 中擦除条目(假设是单页站点)源模式。
So no, you're not crazy it's just not intuitive. ;)
所以不,你不是疯了,只是不直观。;)
回答by backpacker
try (dont forget path in ChartImageHandler key)
尝试(不要忘记 ChartImageHandler 键中的路径)
<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>
回答by Scott Anderson
I posted a way I fixed this problem on the MSDN forum:
我在 MSDN 论坛上发布了解决此问题的方法:
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 :)
好吧,我仍然不知道为什么会出现异常,但我似乎找到了解决方法。我做了一个实验,我将假定有问题的 web.config 复制到一个新项目中,在那里我添加了一个新的 Web 表单和图表控件,并且图表控件使用“UseHttpHandler”选项呈现得很好。这让我相信在我的情况下,实际上并不是 web.config 的问题,所以我回到原始项目并将图表添加到另一个 web 表单作为实验,它奏效了!更令人惊讶的是,在那之后我去了违规页面,它也起作用了!然后我从另一页上取下新图表并检查了原来的违规页面,它又被破坏了。然后我发现如果我在违规页面之前的任何页面上放置图表控件,它会起作用,否则它抛出异常。这些控件非常酷,但我在找到另一个页面并将其放在违规页面的路径上没有问题:)
This fixed the problem but if anyone has any theory why I'd be interested...maybe a bug?
这解决了问题,但如果有人有任何理论为什么我会感兴趣......也许是一个错误?
回答by RunnerRick
More info on this:
更多信息:
I was having trouble with the web.config issues as well and remedied that by ensuring web.config was not open in the code editor when I dragged and dropped the Chart control onto the page. If web.config was not already open, Visual Studio 2010 would make the appropriate modifications.
我也遇到了 web.config 问题,并通过确保当我将 Chart 控件拖放到页面上时未在代码编辑器中打开 web.config 来解决该问题。如果 web.config 尚未打开,Visual Studio 2010 将进行适当的修改。
I was able to successfully get past the "error executing child request" error after successfully applying the web.config issues.
成功应用 web.config 问题后,我能够成功解决“错误执行子请求”错误。
Also regarding usage in an MVC application, I was struggling to implement this in my MVC 2 application (VS2010/.NET 4) and ran into another gotcha.
同样关于在 MVC 应用程序中的使用,我正在努力在我的 MVC 2 应用程序 (VS2010/.NET 4) 中实现这一点,并遇到了另一个问题。
The page's call to ChartImg.axd was resulting in an HTTP 404 error. (I found this using Fiddler.)
该页面对 ChartImg.axd 的调用导致了 HTTP 404 错误。(我使用 Fiddler 找到了这个。)
It turns out the page was trying to access the handler from /MyController/ChartImg.axd instead of /ChartImg.axd (from the root).
结果是页面试图从 /MyController/ChartImg.axd 而不是 /ChartImg.axd(从根)访问处理程序。
I was able to fix the problem by adding this line to my Global.asax.cs file:
通过将这一行添加到我的 Global.asax.cs 文件中,我能够解决这个问题:
routes.IgnoreRoute("{controller}/{resource}.axd/{*pathInfo}");
This might have been the problem for some users who had to resort to changing the Chart.ImageStorageMode property.
对于某些不得不求助于更改 Chart.ImageStorageMode 属性的用户来说,这可能是问题所在。
回答by Mohamed Rasik
This problem was resolved by adding chatImageHandler in the webconfig.
通过在 webconfig 中添加 chatImageHandler 解决了这个问题。
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<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>
for more details:http://www.infinetsoft.com/Post/-Solved-Error-executing-child-request-for-ChartImg-axd/1164#.VyenrNJ97cs
更多详情:http : //www.infinetsoft.com/Post/-Solved-Error-executing-child-request-for-ChartImg-axd/1164#.VyenrNJ97cs
回答by n8CodeGuru
In IIS 6.0 (Server 2003) this error will occur if the httpHandler is missing (see Previous Answer)
在 IIS 6.0 (Server 2003) 中,如果缺少 httpHandler,则会发生此错误(请参阅上一个答案)
Looking into the stack trace it appears that IIS 6.0 assumes that a handler will be loaded. It does an Execute on the statement and the exception is swallowed. Including the following attribute (as shown above) under the httpHandlers in IIS 6.0 fixed this for me.
查看堆栈跟踪,似乎 IIS 6.0 假定将加载处理程序。它对语句执行 Execute 并吞下异常。在 IIS 6.0 中的 httpHandlers 下包含以下属性(如上所示)为我解决了这个问题。
<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
Note that I changed the Version from the previous answer to 4.0.0.0 and tested in Server 2008 (IIS 7.0) and Server 2003 (IIS 6.0)
请注意,我将版本从上一个答案更改为 4.0.0.0 并在 Server 2008 (IIS 7.0) 和 Server 2003 (IIS 6.0) 中进行了测试
回答by Zach Green
Another cause for this problem can be because the application pool is set to 'Classic' mode. My handler was configured correctly, but I was getting the same error.
此问题的另一个原因可能是因为应用程序池设置为“经典”模式。我的处理程序配置正确,但我遇到了同样的错误。
<add name="ChartImg" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
As soon as I switched the application pool to 'Integrated' mode. The chart control started working correctly.
一旦我将应用程序池切换到“集成”模式。图表控件开始正常工作。

