我收到此错误
Invalid temp directory in chart handler configuration [c:\TempImageFiles\].
在运行我的代码时。
最初我得到No http handler was found for request type ‘GET’ error
,我通过引用no http handler
但现在我收到了上述错误 错误的详细信息是
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.
此错误的stackTrace
[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
嗨smarx, 我检查了..他们让我改变
From
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
To
<add key="ChartImageHandler" value="storage=file;timeout=20;" />
在网络配置文件中...
但我的网络配置中没有这一行
我只有这个来定义图表
<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" />
我现在应该做什么......
答案 0 :(得分:50)
您需要使用Web应用程序的文件夹层次结构中的临时目录。在Windows Azure中,您无权访问c:\ TempImages,因此无法使用。
我在这里创建了一个在Windows Azure中运行的ASP.Net图表的快速示例: http://code.msdn.microsoft.com/azurecharts
您仍然可以使用文件存储来存储临时图像:
如果您不想下载示例,请按以下步骤操作:
TempImages
)。temp.txt
或其他内容)添加到此文件夹。开发工具似乎不会发布空目录。将图表的图像位置设置为:
ImageLocation="~/TempImages/ChartPic_#SEQ(300,3)"
将以下内容添加到 web.config 中的 appSettings :
<add key="ChartImageHandler" value="Storage=file;Timeout=20;Url=~/tempImages/;"/>
确保以下内容位于 system.web / assemblies 中:
<add assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
确保以下内容位于 system.web / 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"/>
确保以下内容位于 system.webServer / handlers
中
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
我上传到code.msdn.com的代码就足够了。
答案 1 :(得分:15)
尝试将此密钥添加到您的web.config
<add key="ChartImageHandler" value="storage=file;timeout=20;" />
而不是默认值:
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
答案 2 :(得分:13)
如果更改以下行
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
到
<add key="ChartImageHandler" value="storage=file;timeout=20;" />
不起作用,然后更改属性“storage = file;”的值到“存储=记忆;” 。 它肯定会起作用,因为现在你使用的是内存,而不是文件。
答案 3 :(得分:5)
时间仍在进行,人们仍然有建议。我在迁移过程中遇到过这个问题,所以我想我会加两分钱。
为什么要将它存储在文件系统中,而不是仅仅将其保存在内存中?
<add key="ChartImageHandler" value="storage=memory;deleteAfterServicing=true;"/>
如果文件系统在Azure中存在问题,请不要使用它。
答案 4 :(得分:4)
执行以下操作
1)在web.config中添加或编辑以下密钥。
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" /
2)将IIS_User的写入权限写入此目录,执行以下操作:
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.
现在,您已设置目录并向IIS授予写入权限,以便将临时图像文件写入此文件夹。
现在应该可以了。
答案 5 :(得分:4)
我遇到了同样的问题,我的问题是我的提供商有特殊文件夹和写权限,所以我将TempImagesFile文件夹更改为默认文件夹并且有效。
在我的情况下,具有写权限的文件夹称为上传
web.config编辑:
<appSettings>
<add key="ChartImageHandler" value="Storage=file;Timeout=20;Url=~/upload/;"/>
</appSettings>
希望这也可以帮助其他人;)
答案 6 :(得分:1)
在Windows Azure论坛上查看此答案:http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/92238582-9445-4d15-a5a7-5f24fd4bf646/。
答案 7 :(得分:1)
将您的应用设置更新为此,看看是否可以解决您的问题
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;deleteAfterServicing=false;privateImages=false" />
<add key="ChartImageHandler" value="storage=memory;deleteAfterServicing=true;"/>
</appSettings>
&#13;
答案 8 :(得分:0)
您可以使用BinaryStreaming绕过临时图像缓存。
谷歌应该做其余的事情。
它在Linux上运行,它为Linux路径抛出了InvalidDirectory异常。
(RenderType = “BinaryStreaming”)
<asp:Chart ID="ChartDIN277" runat="server" Width="500" Height="200" RenderType="BinaryStreaming">
<Series>
<asp:Series ChartArea="ChartArea1" ChartType="Pie"
Name="Area"
XValueMember="Label"
YValueMembers="Area"
IsVisibleInLegend="false">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
<Area3DStyle Enable3D="True" LightStyle="Realistic" />
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
代码隐藏:
protected void Page_Load(object sender, EventArgs e)
{
FillChartFromDataBase();
}
public void FillChartFromDataBase()
{
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("Area", typeof(double));
table.Columns.Add("Label", typeof(string));
System.Data.DataRow row = table.NewRow();
row["Area"] = 791;
row["Label"] = "HNF 1";
table.Rows.Add(row);
row = table.NewRow();
row["Area"] = 978;
row["Label"] = "HNF 2";
table.Rows.Add(row);
row = table.NewRow();
row["Area"] = 1262;
row["Label"] = "HNF 3";
table.Rows.Add(row);
row = table.NewRow();
row["Area"] = 1650;
row["Label"] = "HNF 4";
table.Rows.Add(row);
row = table.NewRow();
row["Area"] = 2519;
row["Label"] = "HNF 5";
table.Rows.Add(row);
row = table.NewRow();
row["Area"] = 6071;
row["Label"] = "HNF 6";
table.Rows.Add(row);
// Set chart custom palette
ChartDIN277.Palette = System.Web.UI.DataVisualization.Charting.ChartColorPalette.None;
//ChartDIN277.PaletteCustomColors = New System.Drawing.Color() {System.Drawing.Color.Red, System.Drawing.Color.Blue}
ChartDIN277.PaletteCustomColors = COR.Design.ColorPalette.Generate(System.Drawing.Color.ForestGreen, table.Rows.Count - 1);
// http://student.csdn.net/space.php?uid=383581&do=blog&id=32768
//ChartDIN277.Palette = System.Web.UI.DataVisualization.Charting.ChartColorPalette.None;
//ChartDIN277.PaletteCustomColors = new Color[] { System.Drawing.Color.Red, System.Drawing.Color.Blue};
//// Hide all series empty data point by making them transparent
//Chart.Series[0].EmptyPointStyle.Color = Color.Transparent;
//// Set color for the whole series
//Chart.Series[0].Color = Color.Green;
//// Set color of a single data point
//Chart.Series[0].Points[5].Color = Color.Red;
this.ChartDIN277.DataSource = table;
this.ChartDIN277.DataBind();
}
或者像这样创建一个ashx处理程序
Imports System.Web
Imports System.Web.Services
Public Class ChartCreator
Implements System.Web.IHttpHandler
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "image/jpeg"
Dim yValues As Double() = {10, 27.5, 7, 12, 45.5}
Dim xNames As String() = {"Mike", "John", "William", "George", "Alex"}
Dim mychart As System.Web.UI.DataVisualization.Charting.Chart
mychart = New System.Web.UI.DataVisualization.Charting.Chart
Dim mychartarea As New System.Web.UI.DataVisualization.Charting.ChartArea()
mychartarea.Name = "ChartArea1"
mychartarea.BackColor = Drawing.Color.Transparent
mychart.ChartAreas.Add(mychartarea)
Dim myseries As New System.Web.UI.DataVisualization.Charting.Series()
myseries.ChartArea = mychartarea.Name
myseries.ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Pie
myseries.Name = "Series1"
mychart.Series.Add(myseries)
mychart.BackColor = Drawing.Color.Transparent
mychart.Series(0).Points.DataBindXY(xNames, yValues)
mychart.Series(0).Points.DataBindXY(xNames, yValues)
' http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.rendertype.aspx
' ImageTag, BinaryStreaming, ImageMap
' mychart.RenderType = System.Web.UI.DataVisualization.Charting.RenderType.BinaryStreaming
mychart.ImageType = System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png
'mychart.SaveImage(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "mychart.png"))
mychart.SaveImage(context.Response.OutputStream)
'getResizedImage(context.Request.PhysicalPath,Width,Height);
'context.Response.OutputStream
context.Response.End()
End Sub
ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
答案 9 :(得分:0)
只需在C盘中创建名为“TempImageFiles”的文件夹即可。