asp.net:Invalid temp directory in chart handler co

2019-01-21 10:46发布

I am getting this error Invalid temp directory in chart handler configuration [c:\TempImageFiles\]. While running my code.

Intially I was getting No http handler was found for request type ‘GET’ error which I solved it by referring no http handler

But now I am getting the above error The details of the error are

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.DirectoryNotFoundException: Invalid temp directory in chart handler configuration [c:\TempImageFiles\].

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

The stackTrace of this error

[DirectoryNotFoundException: Invalid temp directory in chart handler configuration [c:\TempImageFiles\].]
   System.Web.UI.DataVisualization.Charting.ChartHttpHandlerSettings.Inspect() +851
   System.Web.UI.DataVisualization.Charting.ChartHttpHandlerSettings.ParseParams(String parameters) +1759
   System.Web.UI.DataVisualization.Charting.ChartHttpHandlerSettings..ctor(String parameters) +619
   System.Web.UI.DataVisualization.Charting.ChartHttpHandler.InitializeParameters() +237
   System.Web.UI.DataVisualization.Charting.ChartHttpHandler.EnsureInitialized(Boolean hardCheck) +208
   System.Web.UI.DataVisualization.Charting.ChartHttpHandler.EnsureInstalled() +33
   System.Web.UI.DataVisualization.Charting.Chart.GetImageStorageMode() +57
   System.Web.UI.DataVisualization.Charting.Chart.Render(HtmlTextWriter writer) +257
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +144
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +583
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +91
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +410
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +118
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +489
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +84
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +713
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +144
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +583
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +91
   System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +91
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +410
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +118
   System.Web.UI.Control.Render(HtmlTextWriter writer) +60
   System.Web.UI.Page.Render(HtmlTextWriter writer) +66
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +144
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +583
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +91
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7761

Can anyone tell me how to solve this problem... Should i have to create a temporary directory manually or what should i do...


Hi smarx, I check it.. They asked me to change

From   
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />

To
 <add key="ChartImageHandler" value="storage=file;timeout=20;" />

in web config file...

But I don't have this line in my web config

I have only this for defining chart

<add name="ChartImg" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,     System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"  />
<add name="ReportViewer" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler,Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

What should I do now....

10条回答
混吃等死
2楼-- · 2019-01-21 11:11

Do the followings

1) Add or Edit the following key in web.config.

<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" /

2) Give writing privilages to IIS_User to this directory, for that do the followings:

a) Go to Windows Explorer.
b) Right click on c:\TempImageFiles Folder.
c) click Properties.
d) Select security tab , click Edit, click Add , Click Advanced, search for IIS_User.
e) Add this IIS_User , give write permission to this user.
f) Save and Close.

Now you have set the directory and given write permission to IIS to write temporary image files to this folder.

It should work now.

查看更多
贪生不怕死
3楼-- · 2019-01-21 11:13

Time still progresses and people still have recommendations. I came across this issue during a migration, so I thought I'd add my two cents.

Why store it in the file system and not just keep it in memory?

<add key="ChartImageHandler" value="storage=memory;deleteAfterServicing=true;"/>

If the file system is an issue in Azure, then don't use it.

查看更多
混吃等死
4楼-- · 2019-01-21 11:20

I had the same issue, my problem was my provider had special folders with write rights, so I changed the TempImagesFile folder to their default folder and it worked.

In my case the folder with write rights was called upload

web.config edits:

<appSettings>
    <add key="ChartImageHandler" value="Storage=file;Timeout=20;Url=~/upload/;"/>
</appSettings>

Hope this can help other too ;)

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-01-21 11:26

try to add this key to your web.config

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

instead of the default one:

<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
查看更多
霸刀☆藐视天下
6楼-- · 2019-01-21 11:27

Update your app setting to this and see if that fixes your problem

 <appSettings>
    <add key="ChartImageHandler" value="storage=file;timeout=20;deleteAfterServicing=false;privateImages=false" />
    <add key="ChartImageHandler" value="storage=memory;deleteAfterServicing=true;"/>
  </appSettings>

查看更多
趁早两清
7楼-- · 2019-01-21 11:29

If changing the following line

<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />

to

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

not works, then change the value of attribute "storage=file;" to "storage=memory;" . It will surely work because now you are using memory, instead of file.

查看更多
登录 后发表回答