私のアプリケーションには、このソリューションと非常によく似た例外処理があります: http://www.devcurry.com/2012/06/aspnet-mvc-handling-exceptions-and-404.html
私のアプリには厄介なバグがあり、SQL が他のプロセスでデッドロックする可能性があります。これはめったに発生しませんが (このため、毎日 1 ~ 2 件のリクエストが失敗します)、それでも発生します。
SQL デッドロック時にページを自動的に更新するにはどうすればよいですか (そして、get 要求でエンド ユーザーからこの方法でエラーを非表示にします)?
Application_Error 関数で実行できますか? または、HandleErrorAttribute のオーバーライドされた OnException で?
編集:
作成した BaseController のいくつかのコードをモックアップしました。
protected override void OnException(ExceptionContext filterContext)
{
Exception ex = filterContext.Exception;
SqlException sex = ex as SqlException;
if (sex != null && sex.Number == 1205)
{
Log.Error("Transaction deadlocked with the following exception:");
Log.Exception(sex);
//I need to write the logic that refreshes the page here.
}
else
{
Log.Error("Application error with the following exception:");
Log.Exception(ex);
}
base.OnException(filterContext);
}
リフレッシュ部分で助けが必要です。