0

我正在使用 Microsoft Visual Web Express 2012 for Web 并且一直在通过 Firefox 进行测试。

当我终于让它工作时,我开始尝试 Chrome 和 IE,但在这两种浏览器上,它都会在一个小窗口中报告 500 内部服务器错误。html 加载正常。我相信这是因为我的网站在选项卡小部件中加载了数据库信息。重新检查 Firefox;看起来不错。重新检查 Chrome 和 IE;同样的错误。

现在可能很明显,但是我已经注释掉了 ajax 代码,并且 IE 和 Chrome 没有报告 500 问题。

我不知道如何找到有关此一般错误的更多详细信息。我试过了

  <system.webServer>
    <httpErrors errorMode="Detailed" />
    <asp scriptErrorSentToBrowser="true"/>
</system.webServer>
<system.web>
  <compilation debug="true" targetFramework="4.5" />
  <httpRuntime targetFramework="4.5" />
</system.web>

在我的 web.config 中,但该窗口仅显示 500。我还尝试取消选中“显示友好的 HTTP 错误消息”和“禁用脚本调试(IE)和(其他)”。我不确定应该发生什么,但 500 消息没有改变。

我确实注意到 Firefox 在从数据库加载时确实显示出奇怪的延迟,但加载后那里的所有数据都很好。

这是有问题的代码。

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Text;
using System.Web.Script.Services;

/// <summary>
/// Summary description for serverAttempt2
/// </summary>
[WebService(Namespace = "http://idontcare.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[ScriptService]

public class serverAttempt2 : WebService
{
  [WebMethod]
  public string GetCustomer(string CustomerID)
  {
    string response = "<p>No customer selected</p>";
    string connect = @"Data Source=localhost\SQLEXPRESS;Initial Catalog=personnet;Integrated Security=Yes;";
    string query = "SELECT TOP 200 * FROM personnet.dbo.accordionTest";
    if (CustomerID != null && CustomerID.Length == 8)
    {
      StringBuilder sb = new StringBuilder();
      using (SqlConnection conn = new SqlConnection(connect))
      {
        using (SqlCommand cmd = new SqlCommand(query, conn))
        {
          cmd.Parameters.AddWithValue("CustomerID", CustomerID);
          conn.Open();
          SqlDataReader rdr = cmd.ExecuteReader();
          if (rdr.HasRows)
          {
            while (rdr.Read())
            {
                sb.Append("Hi.");
                response = sb.ToString();
                /*
                sb.Append("<table style='width:100%;'><tr><td style='width:180px;'>");
                sb.Append(rdr["pro"].ToString() + "</td><td style='width:20%;'>");
                sb.Append(rdr["sn"].ToString() + "</td><td style='width:10%;'>");
                sb.Append(rdr["po"].ToString() + "</td><td style='width:20%;' align='center'>");
                sb.Append(rdr["qty"].ToString() + "</td><td style='width:10%;' align='center'>");
                sb.Append(rdr["status"].ToString() + "</td><td style='width:20%;' align='center'>");
                sb.Append("<input type='image' src='images/temporaryStar.png' /></td></tr></table><div><p></p></div>");
                response = sb.ToString();*/
            }
          }
        }
      }
    }
    return response;
  }
}

我听说过 IE 粗鲁的兼容性惊喜,但我不认为这里是这种情况。

编辑:嗯,我找到了一些东西,但我不知道该怎么做。

'iexplore.exe' (Script): Loaded 'Script Code (Windows Internet Explorer)'. 
Exception was thrown at line 4, column 13743 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 13957 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 10598 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 10598 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 10598 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 10598 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 10598 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 10598 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 10598 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 10598 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 10598 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 10598 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 4, column 4377 in http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a03f6 - JavaScript runtime error: Invalid character
4

1 回答 1

0

您应该将以下内容添加到<system.web>-node 内的 web.config 中:

<customErrors mode="On|Off|RemoteOnly">

要显示详细的错误信息,请将 的值设置modeOff

于 2013-10-03T17:14:59.293 回答