Good error handling practice

2019-04-20 23:02发布

What is a good error handling practice for an asp.net site? Examples? Thanks!

7条回答
迷人小祖宗
2楼-- · 2019-04-21 00:02

One practice that I find to be especially useful is to create a generic error page, and then set your defaultRedirect on the customErrors node of the web.config to that error page.

Then setup your global.asax for logging all unhandled exceptions and then put them (the unhandled exceptions) in a static property on some class (I have a class called ErrorUtil with a static LastError property). Your error page can then look at this property to determine what to display to the user.

More details here: http://www.codeproject.com/KB/aspnet/JcGlobalErrorHandling.aspx

查看更多
登录 后发表回答