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:
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
}
{
//statements
}
catch(type y)
{
//handling exception
}
finally
{
//clean up process
}
No comments:
Post a Comment