<

Question 116


4.2.3 Question

Multiple Choice

Using custom error pages provides a lot of flexibility to an application because it allows for a consistent user experience even when the application has a problem. To take full advantage of this flexibility, you need to be able to create the pages and configure the application to use these pages. What code will provide custom error pages for 404 errors and general exceptions?

  • A. <system.web>
    <customerrors mode="RemoteOnly" defaultredirect="Error/GeneralException">
    <error statuscode="404" redirect="ErrorController.Status404" />
    </customerrors>
    </system.web>
  • B. <system.web>
    <customerrors mode="RemoteOnly" defaultredirect="Error/GeneralException">
    <error statuscode="404" redirect="ErrorController/Status404" />
    </customerrors>
    </system.web>
    <system.webserver>
    <httperrors errormode="Detailed" />
    </system.webserver>
  • C. <system.web>
    <customerrors mode="RemoteOnly">
    <error statuscode="404" redirect="Error/Status404" />
    <error statuscode="GeneralException" redirect="Error/GeneralException" />
    </customerrors>
    </system.web>
    <system.webserver>
    <httperrors errormode="Detailed" />
    </system.webserver>
  • D. <system.web>
    <customerrors mode="LocalOnly" defaultredirect="Error/GeneralException">
    <error statuscode="404" redirect="ErrorController/Status404" />
    </customerrors>
    </system.web>
    <system.webserver>
    <httperrors errormode="Detailed" />
    </system.webserver>

Answer:

B
Explanation
A. Incorrect: This shows only the <system.web> part of the configuration. There is also a need to have an entry in the <system.webserver> node.
B. Correct: This example shows the 404 error status and it sets the default error han­dler to the server error action.
C. Incorrect: This example shows the general exception handler using a status code of GeneralException. The status codes relates to the type of HTTP error that will be handled.
D. Incorrect: The custom error mode is set to mode=”LocalOnly”, which means that users will not see the actual error pages.