What are the ways of handling exceptions in ASP.NET?
There are three ways to handle exceptions in ASP.NET1. 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
}