GlobalFilters.Filters.Add(new ExceptionFilter());
public class ExceptionFilter:IExceptionFilter { public void OnException(ExceptionContext filterContext) { Exception ex = filterContext.Exception; string path= filterContext.HttpContext.Server.MapPath("/"); File.AppendAllText(path,ex.ToString(),System.Text.Encoding.Default); } }