|
/// <summary>
/// 异常过滤器
/// </summary>
public class ExceptionFiter : ExceptionFilterAttribute
{
readonly JavaScriptSerializer ser = new JavaScriptSerializer();
public override void OnException(HttpActionExecutedContext actionExecutedContext)
{
string Method = actionExecutedContext.Request.Method.Method;
var dic = new Dictionary<string, object>();
var logUrl = LogHelpers.Record(actionExecutedContext.Exception.ToString());//生成错误日志文档
dic.Add("success", false);
dic.Add("message", string.Format("系统异常日志:{0}", logUrl));//告知错误日志地址
var json = ser.Serialize(dic);
actionExecutedContext.Response = new HttpResponseMessage(HttpStatusCode.InternalServerError);
actionExecutedContext.Response.Content = new StringContent(json, Encoding.UTF8);
}
}
|
上一篇:js实现下载文件下一篇:js时间控件
|