在一个页面上(我称为 Cashflow.aspx)我有一个 asp.net 图表来绘制一些数据。在我的本地机器上调试时效果很好。但是,当我尝试将站点部署到我的登台服务器时,出现了一个我似乎无法追踪的错误。它失败并重定向回我的 default.aspx 页面。如果我注释掉图表并再次部署页面的其余部分就可以了。
页面:
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<div class="container-fluid">
<div class="row"> </div>
<div class="panel panel-success">
<div class="panel-heading">Cashflow</div>
<div class="panel-body">
<div class="row">
<asp:Chart ID="Chart1" runat="server" Width="1400px" Height="500px">
<Series>
<asp:Series Name="As Bid Projected Cashflow" ChartType="Line" ChartArea="ChartArea1" BorderWidth="3" BorderColor="#86a44a"></asp:Series>
<asp:Series Name="Actual Cashflow" ChartType="Line" ChartArea="ChartArea1" BorderWidth="3" BorderColor="#da8137"></asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" />
</ChartAreas>
</asp:Chart>
</div><div class="row"> </div>
</div>
</div>
</div>
</asp:Content>
代码背后:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Entity;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.DataVisualization.Charting;
using System.Web.UI.WebControls;
namespace MySite
{
public partial class Cashflow : System.Web.UI.Page
{
DataTable tbl;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadData();
decimal maxValue = 0;
Chart1.DataSource = tbl;
Chart1.Series["As Bid Projected Cashflow"].XValueMember = "Period";
Chart1.Series["As Bid Projected Cashflow"].YValueMembers = "AsBidProjectedCashflow";
Chart1.Series["Actual Cashflow"].XValueMember = "Period";
Chart1.Series["Actual Cashflow"].YValueMembers = "ActualCashflow";
Chart1.Series["Actual Cashflow"].Sort(PointSortOrder.Ascending);
Chart1.ChartAreas[0].AxisX.LabelStyle.Angle = 45;
Chart1.ChartAreas[0].AxisY.LabelStyle.Format = "C";
Chart1.Legends.Add("As Bid Projected Cashflow");
Chart1.Legends["As Bid Projected Cashflow"].Position.Auto = false;
Chart1.Legends["As Bid Projected Cashflow"].Position = new ElementPosition(0, 0, 30, 15);
Chart1.Legends["As Bid Projected Cashflow"].Docking = Docking.Right;
Chart1.Legends["As Bid Projected Cashflow"].DockedToChartArea = "ChartArea1";
Chart1.Legends["As Bid Projected Cashflow"].IsDockedInsideChartArea = false;
Chart1.ChartAreas[0].Position.Auto = false;
Chart1.ChartAreas[0].Position = new ElementPosition(0, 15, 105, 85);
Chart1.DataBind();
}
}
private void LoadData()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString;
con.Open();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
tbl = new DataTable();
cmd = new SqlCommand("GetCashflow", con);
cmd.CommandType = CommandType.StoredProcedure;
da.SelectCommand = cmd;
da.Fill(tbl);
}
protected void btnRefreshCharts_Click(object sender, EventArgs e)
{
Response.Redirect("Cashflow.aspx?pnum=" + Request.QueryString["pnum"]);
}
}
}
(相关)Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.web>
<httpHandlers>
<add 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" />
</httpHandlers>
<compilation debug="true" targetFramework="4.6">
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</buildProviders>
<assemblies>
<add assembly="Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
<add assembly="Microsoft.ReportViewer.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
<add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
</assemblies>
</compilation>
<httpRuntime targetFramework="4.6" requestValidationMode="2.0" maxRequestLength="262144000" executionTimeout="110" />
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
<add namespace="Microsoft.AspNet.Identity" />
</namespaces>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
</pages>
</system.web>
<system.webServer>
<!--<modules>
<remove name="FormsAuthentication" />
</modules>-->
<validation validateIntegratedModeConfiguration="false" />
<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>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;" />
</appSettings>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
</configuration>
所有相关的 dll 都已安装并且是最新的。不太确定下一步该去哪里寻找问题。非常感谢任何指针。