public JsonResult Add(ErrorInfo model) { model.Url = Request.UrlReferrer.ToString(); model.RunningTime = DateTime.Now; //model.UID = SessionManager.GetUser().AccountID; _errorInfoService.Add(model); return(Json(new ResultInfo() { ErrorNo = 0, ErrorMsg = "" })); }
public IActionResult Handle() { var feature = HttpContext.Features.Get <IExceptionHandlerFeature>(); var error = feature?.Error; var errorInfo = new ErrorInfo() { ErrorInfoID = 0, UserID = SessionManager.GetUserMaster().UserID, ErrorCode = 500, ErrorMSG = error.Message, StackTrace = error.StackTrace, Url = HttpContext.Request.Path, RunningTime = System.DateTime.Now, SolveBy = "0", ExecSql = "0" }; if (error.GetType().Name == "SysDbException") { SysDbException ex = (SysDbException)error; errorInfo.ExecSql = ex.SqlInfo; } _errorInfoService.Add(errorInfo); var errorResult = new ErrorModel() { ErrorNo = (ErrorTypeEnum)500, ErrorMsg = "错误ID:" + errorInfo.ErrorInfoID }; if (HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest") { return(Json(errorResult)); } else { return(Detail(errorResult)); } }