2

非常に多くの UpdatePanels を持ついくつかのレガシー コードを操作します。UpdatePanels への一部のポストバックがタイムアウトする (デフォルトの 90 秒の制限を超える) 問題が発生しています。これがいつ発生するかを知りたいです。

現在、未処理のすべての例外を Global.asax.cs::Application_Error に記録しています。更新パネルのポストバックで手動でエラーをスローすると、これは問題なくキャプチャされます。Thread.Sleep(100 * 1000) をドロップすると、Application_Error には何も表示されませんが、クライアントでは次のように表示されます。

Uncaught Sys.WebForms.PageRequestManagerServerErrorException: 
    Sys.WebForms.PageRequestManagerServerErrorException: 
        An unknown error occurred while processing the request on the server. 
        The status code returned from the server was: 500

私が知る限り、アプリケーション自体ではなく、サーバー レイヤーがエラーをスローしているため、Application_Error にヒットするものは何もありません。あれは正しいですか?

また、クライアントでこのエラーに気づき、別の POST 操作を実行してログに記録する以外に、このエラーを実際にキャプチャ/ログに記録するためのオプションはありますか?

4

1 に答える 1

0

私が知っている2つのアプローチがあります。

Server-side:
protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)  
{
    ScriptManager1.AsyncPostBackErrorMessage = "An error occurred during the request: " + e.Exception.Message; 
}

Client-side:
<script type="text/javascript">
    // Subscribe to the end request event of the update panel
    function pageLoad()  {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onEndRequest);  
    }

    // You can of course have this emit the error information to whatever control you want, I made up the Label1 object for demonstration purposes
    function onEndRequest(sender, args)  {
        var lbl = document.getElementById("Label1");
        lbl.innerHTML = args.get_error().message;
        args.set_errorHandled(true);
    }
</script>

ここにいくつかのドキュメントがあります:

ASP.NET UpdatePanel コントロールのエラー処理のカスタマイズ

ASP.NET UpdatePanel のエラー処理のカスタマイズ

于 2013-06-27T19:56:49.010 に答える