我在我的项目中使用 Elmah.MVC。我创建了该错误处理程序以生成对客户端的 json 响应:
public class OnHandleErrorAttribute : HandleErrorAttribute
{
public override void OnException(ExceptionContext context)
{
// Ajax
if (context.HttpContext.Request.IsAjaxRequest())
{
// Need create a Json result with generated Elmah error Id ?!?
// How can I get that Id?
context.ExceptionHandled = true;
context.HttpContext.Response.TrySkipIisCustomErrors = true;
context.HttpContext.Response.StatusCode = error;
}
else
{
base.OnException(context);
}
}
}
我需要 elmah 自动生成的 ID (ErrorId od db)。
谢谢