请求大型操作超时



然而,在尝试完成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>"));

}

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

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

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

程序化-您可以将其添加到服务器端代码中:

Server.ScriptTimeout = N;

其中,在两个选项中,N都是请求超时所需的秒数。

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

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

如果是这种情况,您可能需要更改相应的条目,或者,作为替代,更改您的代码绑定内容。

最新更新