
1、在Filter文件夹中创建一个IsExceptionFilter类(类名随意取)
2、使用
3、在访问的页面控制器中添加几个错误
4、在IsExceptionFilter类中获取错误信息并将错误信息存放到文件夹的文本文档中
注:(看不全的代码为)using (FileStream file = new FileStream(filterContext.HttpContext.Server.MapPath("~/errorLog/" + DateTime.Now.ToLongDateString().Replace("/", "-") + "errorlog.txt"), FileMode.Append))
5、效果如下
评价