MS charts not displaying properly on win 2008 server - asp.net

I am displaying two line graphs and two pie charts on my web page. I am not sure why is it happening, but sometimes I see the charts when I run my applications and sometimes I don't. below is my web.confg file settings.
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<allow roles="ANALYST"/>
<deny users="*" />
</authorization>
<httpHandlers>
<add path="ChartImg.axd" verb="*" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
</system.web>
<system.webServer>
<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>
<appSettings>
<add key="ChartImageHandler" value="WebDevServerUseConfigSettings=true;privateImages=false;storage=file;timeout=20;dir=c:\test\;"/>
</appSettings>
apart of this, I have System.web.datavisualization.dll in my bin folder and I am running the application on window server 2008 R2. The whole application is devleoped in .net 4.0. I am not getting any error message. I see the graphs images in the C:\Test folder where I am putting the images, but not on the web page.
Thanks.

It was the browser caching issue. If I clean the browser cache, it works fine.

Related

ASP.net 4.0 Chart Control IIS6 Images not being displayed

Here is my problem, have a Web Application that is being hosted using a Web Farm and Load balancer. The application is running on Framework 4.0, Windows 2003 server and IIS6. Our local host environment is Windows 7 and IIS7.
We noticed intermittent exceptions "The image is not found"and noticed the Web.config was pointing at 3.5
So we made a change to the web.config to point at 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"/>
We are also using a network share to store the chart images which is set in appSettings
<add key="ChartImageHandler" value="storage=file;timeout=300;dir=\\server\webdata\charts\;deleteAfterServicing=false;"/>
after making the changes in the web.config the images would not display on the production server running IIS6 or my local environment running IIS7. So I made a change in all the webforms using the chart control and added ImageStorageMode="UseImageLocation".
After making that change the chart images displayed in IIS7 and IIS6 but in production IIS6 they were being placed in the webform directory and ignoring the handler location (Network Share). My local environment is working fine but I cannot get the production setting correct. All my web.config settings are below and any help would be greatly appreciated.
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=300;dir=\\SERVER\webdata\charts\;deleteAfterServicing=false;"/>
</appSettings>
<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>
<compilation debug="true" defaultLanguage="vb" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<!--IIS 7 Handler Section-->
<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>
Since you use load balancing on servers, it is maybe not finding the correct image location. Why don't you try to use a session to store the images?
<appSettings>
<add key="ChartImageHandler" value="storage=session;timeout=20;" />
</appSettings>
Reference this for more info. We were having the same issue on a web farm. It would be wise to add deleteAfterServicing set to true.

ASP.NET Charting Control not working on production server

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?
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:
Authentication
SessionID
AnonymousID
so the implicit default setting of privateImages=true was keeping me from downloading my images. When I set privateImages=false I had no problems and the charts worked correctly. I set my application to use Windows Authentication, and set privateImages=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.
< add key="ChartImageHandler" value="storage=memory;deleteAfterServicing=true;timeout=20;"/>
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.
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.
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
try this: change Version=4.0.0.0 to Version=3.5.0.0
try this it was resolved in case of web.config runtime error
<pre>
<add key="ChartImageHandler" value="storage=memory;timeout=20;deleteAfterServicing=true;Url=~\temp\"
/>

http error 500.19 - Internal server error

I am trying to get an application (that I didn't develop) running on a windows 2008 r2 64-bit server running IIS 7.5.
I am getting the above stated error - here are more details -
The requested page cannot be accessed because the related configuration data for the page is invalid
Error Code 0x8007007e
I know that the server can access the web.config, because if I make changes to it, the error code changes.
I also know that it is a correct web.config, because it is running successfully on a different server with the same file.
Does anyone have any idea what might be causing this. The error message I am getting really doesn't tell me anything.
I have tried using FailedRequestTracing, but either I don't know how to read those logs or there is no more information there. There are also no errors in the event logs on the server.
Where else can I look to get a better idea of what is happening?
Thanks for any thoughts....
EDIT - Here is the web.config. As I said earlier, it is strange that it is working on another server. I checked to ensure are referenced assemblies are available (as according to the page here, it appear that may be the problem) in the gac.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\temp\;deleteAfterServicing=false;" />
</appSettings>
<connectionStrings>
<!-- removed for this post -->
</connectionStrings>
<system.data>
<DbProviderFactories>
<!--<add name="IBM Informix .NET Data Provider 3.0.0" invariant="IBM.Data.Informix.3.0.0" description="IBM Informix Data Provider 3.0.0 for .NET Framework 2.0" type="IBM.Data.Informix.IfxFactory, IBM.Data.Informix.3.0.0, Version=3.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208"/>-->
</DbProviderFactories>
</system.data>
<system.web>
<httpRuntime maxRequestLength="8192" />
<customErrors mode="Off" />
<sessionState timeout="360" />
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
<clear />
</namespaces>
<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>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /></assemblies></compilation>
<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>
</system.web>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="5000000" />
</webServices>
</scripting>
</system.web.extensions>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
<defaultDocument>
<files>
<add value="index.aspx" />
</files>
</defaultDocument>
<tracing>
<traceFailedRequests>
<add path="*.aspx">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI" verbosity="Verbose" />
</traceAreas>
<failureDefinitions timeTaken="00:00:00" statusCodes="400-600" />
</add>
</traceFailedRequests>
</tracing>
</system.webServer>
</configuration>
It's a bit cheaty, but Microsoft has a page specifically about this problem ... and myriad suggestions for fixing it. Have you gone through it yet?
http://support.microsoft.com/kb/942055
Try this http://windowslivehelp.com/thread.aspx?threadid=3dd85141-a45d-44d9-a94c-3c7d13cfcd5c
I was able to get past this error by disabling compression that is applied by having wsus on the server.
See details here.
Thanks for everyone's help.

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">
<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.
replaced "add path="ChartImg.axd" verb="GET,HEAD with add path="ChartImg.axd" verb="GET,HEAD,POST".
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”

How do I restrict access to files with specific extensions in ASP.NET?

I have in my web application an ADO.NET Entity-Framework *.edmx file.
When I browse in the browser (when the application is running) to an edmx file, it doesn't show the error page like when browsing to a *.cs or vb file, it opens the edmx and shows my model scheme to all the users!!!
How can I avoid that.
You should map the extension to the ASP.NET's System.Web.HttpForbiddenHandler class in web.config. If you are using IIS6, before you could do that, you should have mapped the extension to ASP.NET ISAPI handler.
IIS7 Integrated Mode:
<system.webServer>
<handlers>
<add name="MyForbiddenExtensionHandler"
path="*.edmx"
verb="*"
type="System.Web.HttpForbiddenHandler"
preCondition="integratedMode" />
</handlers>
</system.webServer>
IIS7 Classic Mode. Something like:
<system.web>
<httpHandlers>
<add path="*.edmx"
verb="*"
type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add name="MyExtensionISAPI"
path="*.edmx"
verb="*"
modules="IsapiModule"
scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
</handlers>
</system.webServer>
IIS6 (after mapping the handler to aspnet_isapi.dll in IIS6 configuration):
<system.web>
<httpHandlers>
<add path="*.edmx"
verb="*"
type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpHandlers>
</system.web>
You can do this two ways; firstly in the web.config or secondly in IIS
<system.web>
<httpHandlers>
<add verb="*" path="*.edmx" type="System.Web.HttpForbiddenHandler" />
</httpHandlers>
</system.web>
Here's a link to a microsoft support page that details how to do it in the web config and IIS.
http://support.microsoft.com/kb/815152

Resources