日期:2014-05-17  浏览次数:20323 次

实现对网站错误的统计
在做一个实现IIS7的发布系统。想实现对于已发布网站发生错误的统计

ps: 5xx  4xx 3xx 2xx 1xx 统计这5种的次数

------解决方案--------------------
我用的笨办法,在web.config里指定各种错误指向的页面,当然也可以只指向一个页面,带不同的参数。

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
      <error statusCode="500" redirect="Err01.aspx" />
      <error statusCode="404" redirect="Err02.aspx" />
</customErrors>

然后每个错误页面打开的时候,写入错误日志表,就可以统计了。
------解决方案--------------------
Global

Application_EndRequest

switch(Context.Response.StatusCode)