错误处理

笔记,无代码。

由于每次报错都会经过application_error事件。

所以在Global.asax.cs下的application_error方法下写报错的方法。

一般会吧错误信息写入日志文件,由于会涉及到多线程,所以会吧错误信息发送到队列中,然后直接跳转到指定页面。

在线程池中执行,每次去队列中拿到一个参数,写入到日志中。

由于涉及到可能有不同的写入地方,也许是本地磁盘,也许是数据库,也许是别的地方。

所以可以采用观察者模式,用事件和委托,每一个方式写一个方法注册到委托中,然后直接在发生错误的时候执行委托就好了。

There are two ways of constructing a software design.One is to make it so simple that there are obviously no deficiencies;the other is to make it so complicated that there are no obvious deficiencies.
原文地址:https://www.cnblogs.com/yuanjunqq/p/5744154.html