protected override void OnException(ExceptionContext filterContext) { var ex = filterContext.Exception.GetBaseException(); var result = new OkData { Status = OkData.StatusCode.Error, Data = null, }; try { Response.Clear(); Response.ContentType = "application/json"; Response.StatusCode = 200; throw ex; } catch (MsgException) { result.Msg = ex.Message; } catch (AuthException) { result.Status = OkData.StatusCode.LoggedOut; result.Msg = ex.Message; } catch (Exception) { result.Msg = _hideUnknownException ? "服务器异常" : ex.Message; } finally { var resultData = JsonConvert.SerializeObject(result); Response.Write(resultData); filterContext.ExceptionHandled = true; Response.End(); LogRequest2Db(filterContext, resultData, false, _log2DbAct); } }
public OkResult Ok(OkData customerData) { return(new OkResult(customerData)); }
public OkResult(OkData customerData) : this() { _result = customerData; }