Exception Handling in .net web apps

后端 未结 6 752
盖世英雄少女心
盖世英雄少女心 2021-01-31 12:36

I admit it: I don\'t bother with too much exception handling. I know I should do more but I can never wrap my head around where to start and where to stop. I\'m not being lazy.

6条回答
  •  感情败类
    2021-01-31 13:02

    Well at the very basic level you should be handling the HttpApplication.Error event in the Global.asax file. This should log any exception that occurs to a single place so you can review the stack trace of the exception.

    Apart from this basic level you should ideally be handling exceptions where you know you can recover from them - for example if you expect a file might be locked then handling the IOException and reporting the error back to the user would be a good idea.

提交回复
热议问题