ASP.NET 图表控件无法在生产服务器上运行
我有一个严重依赖图表的应用程序,目前图表可以在 ASP.Net 开发服务器中工作,但是当我尝试发布到我的服务器(Win 2008 Server R2、IIS 7)时,图表不显示。
使用 Firebug,我可以看到对 ChartImg.axd 的调用返回 404,而我在 IE 中得到的只是一个空白图像容器,或者在 Firefox 中什么也没有。到目前为止,我已经搜索了大约 3 或 4 个小时,并尝试了几乎所有推荐的内容,但似乎没有任何效果。
我想使用内存/HttpImageHandler,而不是 ImageLocation 配置。
我的 Web.Config
<appSettings>
<!--<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />-->
<add key="ChartImageHandler" value="storage=memory;timeout=20;deleteAfterServicing=false" />
</appSettings>
<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>
<system.web>
<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>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
</pages>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<customErrors mode="Off"/>
</system.web>
有谁知道我在哪里出错以阻止它在我的服务器上运行?
I have an application that relies heavily on charting and currently the charts will work in the ASP.Net Development Server, but when I try to publish out to my server (Win 2008 Server R2, IIS 7), the charts do not show up.
Using Firebug, I can see that the call to ChartImg.axd returns a 404, and all I get is a blank image holder in IE, or nothing in Firefox. I've searched for about 3 or 4 hours so far, and have tried just about everything recommended, but nothing seems to be working.
I would like to use memory/HttpImageHandler, instead of the ImageLocation configuration.
My Web.Config
<appSettings>
<!--<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />-->
<add key="ChartImageHandler" value="storage=memory;timeout=20;deleteAfterServicing=false" />
</appSettings>
<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>
<system.web>
<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>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
</pages>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<customErrors mode="Off"/>
</system.web>
Does anyone have any ideas where I'm going wrong to keep this from working on my server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我找到了问题的答案,但我相信我的问题具体源于我的代码的运行方式。
一旦我在 ChartImageHandler 的 appSettings 下设置了
privateImages=false
,使用带有文件存储的 ImageLocation 或带有内存存储的 HttpHandler,我的图像就没有问题了。我查看了列表 这里并意识到我的代码没有以下内容:
因此
privateImages=true
的隐式默认设置使我无法下载我的图像。当我设置privateImages=false
时,我没有遇到任何问题,并且图表工作正常。我将应用程序设置为使用 Windows 身份验证,并设置privateImages=true
,现在使用图像位置设置或 HttpHandler 设置生成我的图表。希望这会有所帮助。我知道我花了很长时间四处挖掘却一无所获。
I found the answer to my problem, but I believe that my problem stemmed specifically from how my code runs.
Once I set
privateImages=false
under appSettings for my ChartImageHandler, my images came up with no problem, using ImageLocation with file storage or HttpHandler with memory storage.I looked at the listing here and realized that my code has NONE of the following:
so the implicit default setting of
privateImages=true
was keeping me from downloading my images. When I setprivateImages=false
I had no problems and the charts worked correctly. I set my application to use Windows Authentication, and setprivateImages=true
and my charts are now being generated with either the Image Location setting or the HttpHandler setting.Hopefully this is helpful. I know I spent a long time digging around and got nowhere.
这个配置对我有用。您需要使用内存作为存储。
This configuration work for me. You need to use memory as storage.
这似乎是安全/权限问题。您是否将图表保存到本地文件夹,然后为该文件夹的 IIS 用户和/或网络服务用户分配写入权限。
It seems like security/permission issue. Are you saving charts to local folder, then assign write permission for IIS user and/or network services users for that folder.
在您的网络服务器上安装 Microsoft 图表控件或尝试以下操作:
共享托管环境上的 ASP.Net 图表控件
运行时还要检查 HttpHandler 是否已在 web.config 中的 system.webServer 中注册IIS 7。
Install the Microsoft Chart Controls on your webserver or try this:
ASP.Net Chart Control On Shared Hosting Environment
Also check that the HttpHandler is registered in system.webServer in your web.config when running under IIS 7.
试试这个:将 Version=4.0.0.0 更改为 Version=3.5.0.0
try this: change Version=4.0.0.0 to Version=3.5.0.0
尝试这个,它在 web.config 运行时错误的情况下得到了解决
try this it was resolved in case of web.config runtime error