
- 1.public override void OnException(HttpActionExecutedContext actionExecutedContext)
- {
- //异常日志记录
- LogHelper.WriteError(string.Format("\r\nWebapi Global异常: Post数据:{0}\r\nHeaders:\r\n{1} URL:{2}",
- HttpContext.Current.Request.Form,
- Global.GetHeaders(HttpContext.Current),
- HttpContext.Current?.Request?.Url?.ToString() ?? ""), actionExecutedContext.Exception);
- HttpResponseMessage response = new HttpResponseMessage();
- response.Content = new StringContent("{\"error\":1}");
- //返回调用方具体的异常信息
- if (actionExecutedContext.Exception is NotImplementedException)
- {
- response.StatusCode = HttpStatusCode.NotImplemented;
- actionExecutedContext.Response = response;
- }
- else if (actionExecutedContext.Exception is TimeoutException)
- {
- response.StatusCode = HttpStatusCode.NotImplemented;
- actionExecutedContext.Response = response;
- }
- //如果找不到相应的异常,统一返回服务端错误500
- else
- {
- response.StatusCode = HttpStatusCode.InternalServerError;
- actionExecutedContext.Response = response;
- }
- base.OnException(actionExecutedContext);
- }
评价
排名
3
文章
317
粉丝
22
评论
14
EF连接MySQL连接MySQL数据库操作中文数据乱码解决方法
剑轩 :
准确点应该是ef连接mysql
Layui插件上传图片具体步奏以及获取图片地址
风清月 : 厉害老!
Action与Func的用法-----委托
剑轩 : 可以可以
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术