纽威
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.
 
 
 
 
 

29 lines
1.1 KiB

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;
//cookie时
// 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('登录超时,请重新登录!(" + context.Exception.Message + ")');</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);
}
}
}