0

但是,在尝试完成 Web 进程时,我收到了“请求超时”错误。我不确定我能做些什么来解决这个问题。

我修改了方法,为 for 循环中传递的每个数字创建一个新连接,但它似乎产生了相同的结果。

我更像是一个桌面开发人员,并不太精通 ASP.Net,所以任何可以解决我的问题的观点都会很棒。

我查看了有关 ASP 后台工作人员的信息,这似乎不是一个好方法,并且我增加了服务器设置以允许更高的超时,但如果提供了大量部件,仍然会超时。

我还试图避免在服务器上安排一个单独的进程来执行提交的数字列表。如果需要更多信息来理解这一点,请告诉我。

此外,当我尝试在本地运行应用程序(调试)时,永远不会出现问题,只有当它被放置在实时站点上时。

这是收到的确切错误:

Server Error in '/' Application.

Request timed out.

Description: An unhandled exception occurred during the execution of the current web     request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Request timed out.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[HttpException (0x80004005): Request timed out.]

这是代码:

protected void btnSearch_Click(object sender, EventArgs e)
{
// Clear our reporting panel.
panelHolder.Controls.Clear();

// Store each line in a new array item.
string[] searchlines = txtboxSearch.Text.Replace("\n", "|").Split('|');

// Create a table row containing our main table headers.
panelHolder.Controls.Add(new LiteralControl("<table style=\"width:100%;\">" +
                                                      "   <tr> " +
                                                      "      <td></td> " +
                                                      "      <td>Number</td> " +
                                                      "      <td>Comparison</td> " +
                                                      "   </tr>"));

// Variable to hold the row counts.
int j = 0;

// Store our current web members name for use in our tracking data.
string MemberName = Member.GetCurrentMember().Text;

// This table will be used solely for storing our excel exported data.
System.Data.DataTable dt = new System.Data.DataTable();

// Locate our part comparison results for every line of data supplied by our users.
for (int i = 0; i < searchlines.Count(); i++)
{
    using (SqlConnection con = new SqlConnection(dbConnection))
    {
        // If this array item is not blank we will need to collect information about it.
        if (searchlines[i].Trim() != string.Empty)
        {
            // Determine if data collection (reporting) is turned on.
            Boolean isReporting = DataCollection();
            using (SqlDataReader dr = Connect.ExecuteReader("SelectNumbers]", con,
                                                            new SqlParameter("@Number", searchlines[i].Trim()),
                                                            new SqlParameter("@CurrentMember", MemberName),
                                                            new SqlParameter("@DataCollection", isReporting)))
            {
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        // Add our table rows containing our returned data set.
                        panelCompetitorHolder.Controls.Add(new LiteralControl("<tr><td>" + Convert.ToString(i + 1) + "</td>"));
                        AddTableData(dr, "Part Number");
                        AddTableData(dr, "Comparison");

                        // Go to our next line item.
                        j += 1;
                    }
                }
            }
        }
    }
}

// Add our table to  the panel control.
panelHolder.Controls.Add(new LiteralControl("</table>"));

}

4

1 回答 1

1

您的问题可能在于 IIS 假定处理给定请求的最长时间。默认情况下,该值为 90 秒。您可以通过以下几种方法设置不同的时间:

通过Web.configweb.config - 在您的文件中检查/添加此条目:

<system.web>
    <httpRuntime executionTimeout="N" />
</system.web>

以编程方式- 您可以将其添加到您的服务器端代码中:

Server.ScriptTimeout = N;

N在这两个选项中,请求超时所需的秒数在哪里。

applicationhost.config此外,如果服务器或machine.config文件中存在条目,您的值可能会被取代/忽略,如下所述:

http://www.iis.net/configreference/system.applicationhost/sites/sitedefaults/limits

如果是这种情况,您可能必须更改相应的条目 - 或者,作为替代,更改您的代码隐藏内容。

于 2013-12-02T13:54:41.810 回答