サイトで例外が発生するたびに、例外の詳細が記載されたメールが届くように、属性を作成しています。これまでのところ、例外が発生した場合に属性コードが起動しないようです。
public class ReportingAttribute : FilterAttribute, IExceptionFilter
{
public void OnException(ExceptionContext filterContext)
{
// This will generate an email to me
ErrorReporting.GenerateEmail(filterContext.Exception);
}
}
次に、コントローラーの上で実行しています。
[ReportingAttribute]
public class AccountController : Controller
ErrorReporting.GenerateEmail(ex)
それを行う別の方法は、もちろん私のキャッチブロックの中に入れることですか?もっと簡単な方法があるに違いありませんか?そのため、これを処理するための属性を作成することを考えました。