Handling chart generated images using Chart Http Handler

I had used Microsoft chart control in one of my project and in my local server it is working fine but in thirdparty webserver I am getting below error,

Error:

The temp directory in chart handler configuration is not accessible [D:/webdata/abc.com/TempFiles]

Exception Details:
System.UnauthorizedAccessException: The temp directory in chart handler configuration is not accessible

Solution :

When the Chart.RenderType property is set to ImageTag, the Chart control is rendered as standard image (img) tag. Displaying an image in current web browsers is a two stage process:

first the browser renders the html page and then downloads the image from specified Url. Because real chart image is created during web page processing the Chart needs a storage where image will stay until the browser requests it.

You can specify how the Chart control manages the image files. To do this, use the ImageStorageMode property. By default, the ImageStorageMode property is set to UseHttpHandler. This causes the Chart control to use the ChartHttpHandler that is registered in the web.config file to manage the rendered chart images.

When we drag a Chart control from the Toolbox onto the design surface of the ASP.NET page, the ChartHttpHandler is automatically registered in the web.config file as “ChartImageHandler”.

You can configure ChartImageHandler’s behavior in theelement. The applicable code section is provided below with the automatically generated settings, please find commented code which trows an error.

<appSettings>
<!–<add key=”ChartImageHandler” value=”storage=file;timeout=20;dir=c:\TempImageFiles\;” />–>
<add key=”ChartImageHandler” value=”storage=memory;timeout=20;deleteAfterServicing=false” />
</appSettings>

Storage mode :
Three options are available:

file: Store the rendered chart images as temporary files. You must also specify the storage location in the url or dir parameter. In a server cluster or a multiple-process site, you must specify the dir parameter.

memory: Store the rendered chart images in the memory space of the running process. Do not use this option in a server cluster or a multiple-process site.

session: Store the rendered chart images in a session variable.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s