简体   繁体   English

ASP.NET 4.0 WebForms URL重写中断MS图表

[英]ASP.NET 4.0 WebForms URL Rewrite breaks MS Chart

I've added the new Chart control to my project and it works well. 我已经将新的Chart控件添加到我的项目中,并且效果很好。 I've set the 我已经设定了

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

<handlers>
  <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"  />
</handlers>

Everything is fine as long as I use the "/host/Poll.aspx" path in my browser. 只要在浏览器中使用“ /host/Poll.aspx”路径,一切都很好。 Things break when switching over to the rewritten URL "host/poll/". 切换到重写的URL“ host / poll /”时,事情中断了。 I am getting the "System.Web.HttpException was unhandled by user code Message=Error executing child request for ChartImg.axd." 我收到“用户代码Message = Error对ChartImg.axd执行子请求时未处理System.Web.HttpException。” exception. 例外。

Any ideas how to fix it? 任何想法如何解决? Thank you very much! 非常感谢你!

I cant actually try this at the moment but how about "~/ChartImg.axd" 我目前无法实际尝试,但是“〜/ ChartImg.axd”如何?

Failing that try using image locations 尝试使用图像位置失败

<add key="ChartImageHandler" value="Storage=file; Timeout=20; Url=~/Temp/Charting/;"/>

Edit: And update your chart html 编辑:并更新您的图表html

<asp:Chart ID="chrt1" runat="server" Width="550px" Height="400px" 
    SuppressExceptions="True" ImageStorageMode="UseImageLocation"
    ImageLocation="~/Temp/Charting/ChartPic_#SEQ(1000,30)">

And make sure the directory you are writing to exists. 并确保要写入的目录存在。 I normally do this on app start in the global 我通常在全球范围内的应用启动时执行此操作

in case you upgrade your website from .Net 3.0 to .Net 4.0 and using IIS 7 you must insert some line in your webconfig like here : 如果您将网站从.Net 3.0升级到.Net 4.0并使用IIS 7,则必须在webconfig中插入一些行,如下所示:

<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
        <handlers>
            <remove name="ChartImageHandler"/>
            <add name="ChartImageHandler" preCondition="integratedMode" verb="*" 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM