You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using NFine.Code; using System.Text; using System.Web.Mvc;
namespace NFine.Web { public class HandlerErrorAttribute : HandleErrorAttribute { public override void OnException(ExceptionContext context) { base.OnException(context); context.ExceptionHandled = true; context.HttpContext.Response.StatusCode = 200; context.Result = new ContentResult { Content = new AjaxResult { state = ResultType.error.ToString(), message = context.Exception.Message }.ToJson() }; //StringBuilder sbScript = new StringBuilder();
//sbScript.Append("<script type='text/javascript'>alert('登录超时,请重新登录!');top.location.href = '/Login/Index';</script>");
//context.Result = new ContentResult() { Content = sbScript.ToString() };
} private void WriteLog(ExceptionContext context) { if (context == null) return; var log = LogFactory.GetLogger(context.Controller.ToString()); log.Error(context.Exception); } } }
|