I'm experiencing an intermittent error when cancelling the loading of a RadChart. During the load of a chart I log out of the application which causes the session to clear. After that I do a redirect to a log in page. Sometimes it works with no problem and sometimes I get an error. It is not consistent and I am testing locally on my development server.
Here is the error:
Error loading Radchart image.
You may also wish to check the ASP.NET Trace for further details.
Display stack trace?
Here are my configurations:
<!-- this is appsetting for chart image -->
<add key="ChartImage_axd" value="storage=session;timeout=20;dir=~\img\chartimage" />
<system.web>
<httpHandlers>
<add path="ChartImage.axd" verb="*" type="Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI, Version=2011.1.413.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false" />
</httpHandlers>
<httpRuntime maxRequestLength="2048000" executionTimeout="3600" />
<sessionState timeout="60"/>
</system.web>
<system.webServer>
<handlers>
<add name="ChartImage_axd" verb="*" preCondition="integratedMode" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" />
</handlers>
</system.webServer>
Do you have any ideas on how I can fix the intermittent error?
Thank you!
7 Answers, 1 is accepted
Here is how it works -- RadChart generates an image and places it in the session (this is by default). It also renders an <img> tag with src="ChartImage.axd?..." with certain arguments. When ChartImage.axd is requested the ChartHttpHandler retrieves the image from session. So, if you clear the session before the ChartHttpHandler has managed to retrieve the image you will get this error. A possible solution here would be to set UseSession=false and provide a folder where the chart will store temporarily the images as described here. This way RadChart will not use the session, so you should not experience such issues.
Best regards,
Ves
the Telerik team

I set UseSession=false and provide a folder where the chart will store temporarily the images as described above. Now I don't get error but I could see my old .png files sitting at that tempfolder. Do I've to code to delete those at end of application? if yes then how can I do that?
ChartHttpHandler is supposed to delete the image files, however if this is not possible (e.g. file is locked) they will remain in the folder. Here is sample code, which you can add to Application_End event handler to delete them:
string
[] files = Directory.GetFiles(
MyTempImagesFolder
);
foreach
(
string
file
in
files)
File.Delete(file);
Best regards,
Ves
the Telerik team

still it is not working .........
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
Dim files As String() = Directory.GetFiles("TempImg", "*.png")
For Each file As String In files
System.IO.File.Delete(file)
Next
End Sub
And
we are using Ajax Rad Chart for for live application i mean my chart will refresh for every second.it is working fine in IE browser and it is getting slow in Google Chrome
This code will be executed only on application end. If you need to clear the files more often, you may need to develop a separate application to delete the files in this folder.
Best regards,
Ves
the Telerik team

Can you please show us the related parts of the web.config file? In addition -- HttpHandlerUrl property needs to be set in case you use url rewriter. Do you use one?
Best regards,
Ves
the Telerik team