I have a situation in a webforms application using the Chart Control where the chart will often display as a broken image, and only sometimes display correctly. This only occurs once I publish the application to the hosting server, it always renders perfectly on my local development environment.
I have posted the demo
here. You'll see on each refresh of the page - charts will sometimes render and sometimes not. Is there something I'm missing? Is this a problem with my web hosting provider?
<appsettings>
<add key="ChartImageHandler" value="storage=session;timeout=60;privateImages=false;">
<form id="form1" runat="server">
<asp:Button ID="btnPostBack" runat="server" Text="Do Postback" OnClick="btnPostBack_Click" />
<table>
<tbody><tr>
<td>Bind On PageLoad
<asp:Chart ID="Chart1" runat="server">
<series>
<asp:Series Name="Series1" Color="LimeGreen">
<chartareas>
<asp:ChartArea Name="ChartArea1">
</td>
<td>Bind On Postback
<asp:Chart ID="Chart2" runat="server">
<series>
<asp:Series Name="Series1" Color="Brown">
<chartareas>
<asp:ChartArea Name="ChartArea1">
</td>
<td>Bind On PageLoad EnableViewState is TRUE
<asp:Chart ID="Chart3" runat="server" EnableViewState="True">
<series>
<asp:Series Name="Series1" Color="Goldenrod">
<chartareas>
<asp:ChartArea Name="ChartArea1">
</td>
<td>Bind On Postback EnableViewState is TRUE
<asp:Chart ID="Chart4" runat="server" EnableViewState="True">
<series>
<asp:Series Name="Series1">
<chartareas>
<asp:ChartArea Name="ChartArea1">
</td>
</tr>
</tbody></table>
</form>
protected void Page_Load(object sender, EventArgs e)
{
BindChart(Chart1);
BindChart(Chart3);
}
protected void btnPostBack_Click(object sender, EventArgs e)
{
BindChart(Chart2);
BindChart(Chart4);
}
private void BindChart(System.Web.UI.DataVisualization.Charting.Chart chrt)
{
List<chartitem> chartPoints = new List<chartitem>();
chartPoints.Add(new ChartItem("One", 1));
chartPoints.Add(new ChartItem("Two", 2));
chartPoints.Add(new ChartItem("Three", 3));
chrt.Series[0].XValueMember = "XValue";
chrt.Series[0].YValueMembers = "YValue";
chrt.DataSource = chartPoints;
chrt.DataBind();
}
public class ChartItem
{
public string XValue { get; set; }
public double YValue { get; set; }
public ChartItem(string x, double y)
{
this.XValue = x;
this.YValue = y;
}
}
What I have tried:
I have tried both memory and session as a storage option. I cannot use file storage as I get permission errors.