Tutorial 9 (Answer)
Tutorial 9 (Answer)
Tutorial 9 (Solution)
1. There are four different types of errors that might occur during the development of a
Web application, which are. parser error compilation error configuration error runtime error Describe and differentiate the four types of errors above. Provide example to support your answers. Please refer to notes
c. There are 3 different exception handling mechanisms that we can use to handle
an exception. State the 3 mechanisms and differentiate them. Please refer to notes
b. We
can use try...catch, Page_Error() method or Application_Error() method to catch the potential errors. Suggest which approach is better to catch the potential errors above, and justify your answer.
Both answers can be accepted (but try...catch maybe better). Student must explain his/her choice accordingly. Examples of answers: You are just testing a block of code that could fail, and you are anticipating a particular exception that may occur. Therefore it is easier to use TryCatch block. If you use a trycatch block, a problem is more easily corrected where it occurs. If the user can help correct a problem, the page needs to return to the same place so the user has a context for understanding what to do. A page-level handler returns you to the page, but there is no longer anything on the page because instances of controls are not created. For Page_Error event handler, to provide the user any information, you must specifically write it to the page. Unlike Page_Error(), trycatch can handle specific exception, such as DivideByZeroException, and return its message easily. You would probably use a page-level error handler to log unhandled errors or to take the user to a page that can display helpful information. So if the exception is already anticipated, it is better to use TryCatch statement. [Reference: http://msdn.microsoft.com] c. Write the necessary C# code to demonstrate each of the approaches below to handle the potential errors in Figure 1.
To avoid users to see the technical details of exception, which we can provide them a userfriendly error page
Protocol -- HTTP/1.1