Go Back   Wiki NewForum > Career Forum > Tech Forum & Tutorial > ASP.NET Forum & Tutorial

Sponsored Links

Views: 1269  
Thread Tools Rate Thread Display Modes
Old 05-31-2009, 04:35 AM
bholus7 bholus7 is offline
Join Date:
Apr 2009
Posts: 1,322
Default ASP.NET exception handling technique - Interview questions

ASP.NET exception handling technique - Interview questions

Question - Define Exception handling in ASP.NET.

Answer - Exceptions or errors are unusual occurrences that happen within the logic of an application. The CLR has provided structured way to deal with exceptions using Try/Catch block. ASP.NET also supports exception handling through server events such as Page_Error and Application_Error events.

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

Answer - There are three ways to handle exceptions in ASP.NET
Try/catch/finally block.
Using Events like Page_Error and Application_Error
Using Custom error page

Question - Explain Try/catch block of exception handling.

Answer - You can enclose code in Try/Catch/Finally block. You can catch all exceptions in the catch block. The third part of this block is finally. It is executed irrespective of the fact that an exception has been raised.
Question - Define Error Events.

Answer - ASP.NET supports events that occur when any unhandled exception occurs in an application. These events are called as Error Events.

ASP.NET provides two such events to handle exceptions
  • Page_Error : This is page event and is raised when any unhandled exception occur in the page.
  • Application_Error: This is application event and is raised for all unhandled exceptions in the ASP.NET application and is implemented in global.asax
The Error events have two methods to handle the exception:
  • GetLastError: Returns the last exception that occurred on the server.
  • ClearError: This method clear error and thus stop the error to trigger subsequent error event. .
Question - Define Custom Error Pages.

Answer - There are many errors that canít be trapped in the application code like page not found. To intercept this kind of error, ASP.NET supports Custom Error Pages that can be specified at two places:
  • Specify application-wide error page settings in the customErrors section of the Web.config file.
  • Specify an error page for a specific Web form in the ErrorPage attribute of the Web formís @ Page directive
Question - Why is exception handling important for an application?

Answer - .Exception handling is used to prevent application from being stuck due to unusual occurrences. If the exceptions are handled properly, the application will never get terminated abruptly.
Question - When can you use tracing with exception handling?

Answer - You can use tracing with exception handling to log unanticipated exception to the trace log. The log file can be used to diagnose unanticipated problems and thus can be corrected.

Reply With Quote

New topics in ASP.NET Forum & Tutorial

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2019, vBulletin Solutions, Inc.