开发者

ASP.NET Chart: What's wrong with my web.config. I can't display a chart

I just created a web page having a barebone chart with a few data points to test. On localhost, the chart is displayed as expected with no problem. But when I deployed to my webhost I got a 500 - Internal Server Error

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

Here's the web.config uploaded by Visual Studio. Could you tell me what's missing or wrong in this web.config. The appSettings look suspicious with a dir in C:, but how do I change it? Thanks.

<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
</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">
 开发者_如何学JAVA <assemblies>
    <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  </assemblies>
</compilation>
 </system.web>
</configuration>


try this link http://asifhuddani.wordpress.com/2010/10/07/chart-control-asp-net-4-0-and-iis-7-problem/

and then delete dir=c:\TempImageFiles\; from web.config


I had the same problem, namely a 500 server error adding in the same section. Two changes resolved the 500 serve error.

  1. replaced "add path="ChartImg.axd" verb="GET,HEAD with add path="ChartImg.axd" verb="GET,HEAD,POST".

  2. Added line after system.webServer tag:

    [validation validateIntegratedModeConfiguration="false"/]

I had to replace < with [, otherwise the preview did not show the tag.


Problem is the temporary directory. It could be because:

  • The directory no exists,
  • The user has no permission to the directory,
  • You are pointing to the wrong directory, or
  • when you move your programs form a local PC to a server you are no longer pointing to a local file, you are pointing to a URL

Solutions:

  • If you are using a web server, the easy and lazy solution is create a directory named temp where the aspx is located. In the same directory and give the users permission to modify.

  • If you are using a local PC you can use memory instead of file. No use this in the web server because is to heave for many users, but use:

    <add key="ChartImageHandler" value="Storage=memory;Timeout=20;"/>
    
  • If you are using a web server, the best option is use a url instead of a file like this:

    <add key="ChartImageHandler" value="storage=file;timeout=20;url=~/temp" />
    

    You can use ~ / . or http://…

To Add permission to the ISS user, could be your user pool, windows user or any user as you used before. If you use Windows authentication, then you should grant permission to the user named “Domain Users”. Some people add permission to the user everybody. This permission should include “Modify”

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜