Methods to handle exceptions in a web project using C#

前端 未结 5 947
被撕碎了的回忆
被撕碎了的回忆 2021-02-09 01:36

What is the best way to handle exceptions occurring in catch statements. Currently we are writing the exception message to response object\'s write method. But I want a solution

5条回答
  •  后悔当初
    2021-02-09 02:12

    As REA_ANDREW said, use Health Monitoring along with the custom error pages.

    One thing he didn't say explicitly is that you should avoid the style of programming that puts try/catch blocks around everything. Health Monitoring will log unhandled exceptions, and Custom Error Pages will display to the user whatever you want the user to see about the error (if anything). But this will only happen if you do not catch the exceptions, so just leave them alone and let them propagate.

提交回复
热议问题