ASP.NET 2.0 Performance Inspection Questions - Exception Management

From Guidance Share

Jump to: navigation, search

- J.D. Meier, Srinath Vasireddy, Ashish Babbar, Rico Mariani, and Alex Mackman




Contents

Have you implemented an error handler in Global.asax?

Although implementing an error handler in Global.asax does not necessarily increase performance, it helps you to identify unexpected exceptions that occur in your application. After you identify the exceptions that occur, take appropriate action to avoid these exceptions.


Do you use try/finally on disposable resources?

Ensure that disposable resources are released in a finally block to ensure they get cleaned up even in the event of an exception. Failing to dispose of resources is a common problem.


Does your code avoid exceptions?

Your code should attempt to avoid exceptions to improve performance because exceptions incur a significant overhead. Use the following approaches:

  • Check for null values.
  • Do not use exceptions to control regular application logic.
  • Do not catch exceptions you cannot handle and obscure useful diagnostic information.
  • Use the overloaded Server.Transfer method Server.Transfer(String,bool) instead of Server.Transfer, Response.Redirect, and * * Response.End to avoid exceptions.


Related Items

For more information about the questions and issues raised in this section, see ASP.NET 2.0 Performance Guidelines - Exception Management.

Personal tools