For my web application created an aspx page which should display the ASP.NET Charts. Able to generate the charts but not displaying on the page. I can see the generated charts in my 'Temp charts' folder.
I am using ASP.Net 4 and .NET Framework 4 and done the following.
Code is:
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.WebControls.WebParts" %>
<%@ Import Namespace="System.Xml.Linq" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Web.UI.DataVisualization" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.UI.DataVisualization.Charting" %>
<%@ Page Language="C#" %>
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:Chart ID="Chart1" runat="server" ImageLocation="~/TempCharts/ChartPic_#SEQ(200,2)" Height="200px" Width="535px" >
<BorderSkin />
<Series>
<asp:Series Name="Series1" ChartType="Pie" YValuesPerPoint="2" >
<Points>
<asp:DataPoint AxisLabel="4 letter" YValues="20,0" />
<asp:DataPoint AxisLabel="5 letter" YValues="10,0" />
<asp:DataPoint AxisLabel="6 letter" YValues="5,0" />
<asp:DataPoint AxisLabel="7 letter" YValues="16,0" />
</Points>
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" >
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
</div>
</form>
</body>
</html>
And added the below to web.config:
<appSettings>
<add key="ChartImageHandler" value="storage=memory;timeout=30;" />
</appSettings>
<system.webServer>
<handlers>
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,
System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>
But I am not able to see the Chart on page. Am I missing any?
Solved: Added ImageStorageMode attribute to <asp:Chart>
and set value "UseImageLocation" .
try to change your appSetting from
to this
When set to true, the generated image can only be downloaded by its owner if some of the following types of identifications are enforced:
The user is authenticated.
AnonymousID is enabled.
SessionID is available.
The default value is true.