4

output.aspxページに次のエラーが表示されることがあります。

例外の詳細:System.Web.HttpException:リクエストがタイムアウトしました。

ソースエラー:

現在のWebリクエストの実行中に、未処理の例外が生成されました。例外の発生源と場所に関する情報は、以下の例外スタックトレースを使用して識別できます。

スタックトレース:

[HttpException(0x80004005):リクエストがタイムアウトしました。]

この例外をキャッチするのは良い考えですか?output.aspx.csにPage_Loadがあり、その関数がRunTable()を呼び出すので、どこでそれを行いますか。その関数のコンテンツの周りにtrycatchブロックを配置する必要がありますか?

4

1 に答える 1

6

アプリケーションレベルで例外をキャッチ

    void Application_Error(object sender, EventArgs e)
{
  // Code that runs when an unhandled error occurs

  // Get the exception object.
  Exception exc = Server.GetLastError();

  // Handle HTTP errors
  if (exc.GetType() == typeof(HttpException))
  {
    // The Complete Error Handling Example generates
    // some errors using URLs with "NoCatch" in them;
    // ignore these here to simulate what would happen
    // if a global.asax handler were not implemented.
      if (exc.Message.Contains("NoCatch") || exc.Message.Contains("maxUrlLength"))
      return;

    //Redirect HTTP errors to HttpError page
    Server.Transfer("HttpErrorPage.aspx");
  }

  // For other kinds of errors give the user some information
  // but stay on the default page
  Response.Write("<h2>Global Page Error</h2>\n");
  Response.Write(
      "<p>" + exc.Message + "</p>\n");
  Response.Write("Return to the <a href='Default.aspx'>" +
      "Default Page</a>\n");

  // Log the exception and notify system operators
  ExceptionUtility.LogException(exc, "DefaultPage");
  ExceptionUtility.NotifySystemOps(exc);

  // Clear the error from the server
  Server.ClearError();
}
于 2012-08-30T19:05:44.613 に答える