Methods to handle exceptions in a web project using C#

前端 未结 5 952
被撕碎了的回忆
被撕碎了的回忆 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 01:48

    Good for you for wanting to fix this. Writing exception messages directly back to the user can pose a significant security risk -- as you've figured out already, exception messages can contain lots of information that could help a malicious user gain access to your site.

    I'd take a look at ELMAH (Error Logging Modules and Handlers); it's an easy way to add logging of detailed errors to your web app.

提交回复
热议问题