Try/catch block method of exception handling

What are the ways of handling exceptions in ASP.NET?

There are three ways to handle exceptions in ASP.NET

1. Try/Catch/Finally block.
2. Using Events like Page_Error and Application_Error.
3. Using Custom error page.

- The try block encloses the statements which throws an exception.
- The catch block handles any exception if one exists.
- The finally block can be used for clean up process.

Example:
try
{
   //statements
}

catch(type y)
{
   //handling exception
}
finally
{
   //clean up process
}
Error Events method of exception handling - ASP.NET
ASP.NET - Error Events method of exception handling - You can enclose code in Try/Catch/Finally block.......
Custom Error Pages method of exception handling - ASP.NET
ASP.NET - Custom Error Pages method of exception handling - ASP.NET supports events that occur when any unhandled exception occurs in an application. These events are called as Error Events...
Why is exception handling important to an application?
ASP.NET - Why is exception handling important to an application? - Exception handling is used to prevent application from being stuck due to unusual occurrences...
Post your comment