【问题标题】:Run time error after hosting the website托管网站后运行时错误
【发布时间】:2016-08-11 13:06:28
【问题描述】:

我使用 C# 创建了一个网站。当我在我的电脑上运行它时它工作得很好。但它在托管后运行时会产生运行时错误。在这里,我添加了我得到的错误的屏幕截图。enter image description here

这是asp代码

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
    CodeBehind="surrenderLetterT.aspx.cs" Inherits="Letters_Auto_Generator.surrenderLetterT" %>

<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <CR:CrystalReportViewer ID="CrystalReportViewer3" runat="server" AutoDataBind="true"
        Height="1039px" ReportSourceID="CrystalReportSource2" Width="901px" />
    <CR:CrystalReportSource ID="CrystalReportSource2" runat="server">
        <Report FileName="CrystalReport2.rpt">
        </Report>
    </CR:CrystalReportSource>
</asp:Content>

这是 .cs

中的代码
 public partial class surrenderLetterT : System.Web.UI.Page
{
   DBClass db = new DBClass();
   protected void Page_Load(object sender, EventArgs e)
   {
        string policyNo = Session["PolNo"].ToString();
        string eid = Session["EMPID"].ToString();

        //CrystalReportViewer1.Visible = true;
        DataSet printdtls = db.print(policyNo);
        DataSet dsUserInfo = db.getdesignation(eid);

        string Ename = dsUserInfo.Tables[0].Rows[0]["Name"].ToString();
        string Desig = dsUserInfo.Tables[0].Rows[0]   ["Designation"].ToString();
        if (printdtls.Tables[0].Rows.Count > 0)
        {
            ReportDocument myReport = new ReportDocument();
            myReport.Load(Server.MapPath("~\\CrystalReport2.rpt"));
            myReport.SetDataSource(printdtls.Tables[0]);
            myReport.SetParameterValue("PolicyNo", policyNo);
            myReport.SetParameterValue("Name", Ename);
            myReport.SetParameterValue("designation", Desig);

            CrystalReportViewer3.ReportSource = myReport;
        }
   }
}

【问题讨论】:

  • 如果可能,请关闭或设置仅远程自定义错误以查看确切的异常
  • 请先关闭自定义错误。所以我们可以真正看到错误是什么。然后重新发布截图
  • 这不是错误描述,这是告诉您您的配置设置为隐藏错误的页面。
  • 谁能告诉我如何关闭或设置仅远程自定义错误?
  • 我只是将其发布为答案,您可以在 web.config 中找到这些

标签: c# asp.net runtime-error hosting


【解决方案1】:

要真的显示错误请将此行添加到system.web节点

<customErrors mode="Off"/>

这一行到system.webServer节点

<httpErrors existingResponse="PassThrough"/>

【讨论】:

  • 请再给我一个帮助。我不知道如何在评论中添加图片。我该怎么办?添加代码后,我有错误的屏幕截图
  • 抱歉,我认为还不能在评论中添加图片。您可以编辑您的帖子并在那里发布屏幕截图。
  • 好的,刚刚添加了新图片。请看一下
  • 抱歉,仅凭您发布的屏幕截图,我们无法确定是什么原因导致您的网站崩溃。虽然我建议在您的程序中搜索 #if DEBUG 行。甚至是对数据库的访问权限。
  • 谢谢,我马上试试
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-28
  • 2020-07-26
相关资源
最近更新 更多