ASP.NET MVC ApiController过滤器处理返回结果

来源:互联网 发布:避孕套用途知乎 编辑:程序博客网 时间:2024/06/05 05:37
    public class OpenIdAutoDecryptAttr : ActionFilterAttribute    {        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)        {            base.OnActionExecuted(actionExecutedContext);            var objectContent = actionExecutedContext.Response.Content as ObjectContent;            if (objectContent != null && objectContent.Value != null && (objectContent.Value.GetType().BaseType == typeof(Parm) || objectContent.Value.GetType() == typeof(Parm)))            {                Parm parm = (Parm)objectContent.Value;                if (!String.IsNullOrEmpty(parm.ErrMsg))                {                    LogUtil.DoLog("ErrMsg Before", parm.ErrMsg);                    Regex regex = new Regex(@"(ORA-[0-9]{1,}:)(.*)\r\n(.*)");                    if (regex.IsMatch(parm.ErrMsg))                    {                        parm.ErrMsg = regex.Match(parm.ErrMsg).Result("$2").Trim();                    }                    LogUtil.DoLog("ErrMsg After", parm.ErrMsg);                }            }        }    }

0 0
原创粉丝点击