1

私はこの例外があります:

Server Error in '/datalab' 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.]

しかし、Global.asax ファイルを /datalab および /datalab/powerstats ディレクトリに追加しました (datalab ディレクトリはルートであり、タイムアウトしているページは datalab/powerstats/output.aspx です)。

<%@ Application Language="C#" %>

<script runat="server">



void Application_Error(object sender, EventArgs e) 
{ 
    Exception exc = Server.GetLastError();

  // Handle HTTP errors
  if (exc.GetType() == typeof(HttpException))
  {
  Response.Write("<h2>Global Page Error</h2>\n");

        // 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");
        return;
    }


}



</script>

この例外をキャッチするにはどうすればよいですか? なぜ捕まらない?

4

2 に答える 2

1

このApplication_Errorイベントは、未処理の例外が発生したときに呼び出されます。

内部サーバー エラー 500 応答が既にクライアントに送信されているため、戻って応答を変更することはできません。

問題に対する答えは、タイムアウトの理由を修正するか、プログラムでタイムアウト期間を長くすることです。web.config でこれを行うには、次を追加してみてください。

<httpRuntime executionTimeout="<numOfSeconds>" />

http://msdn.microsoft.com/en-us/library/e1f13641(v=vs.71).aspxを参照してください。

于 2012-08-30T20:51:36.957 に答える
0

以前にスタック トレースを使用したことがありますか?

それらの使用方法については、MSDN のドキュメントを参照してください。アプリケーションに応じて、異なるタイプのスタック トレースがあります。

于 2012-08-30T20:52:28.923 に答える