How handle HTTP errors with web config file
How handle HTTP errors with web. config file How to configure and deploy ASP. NET applications #11 Roshan Ghale #21 Wan-Ting Lee #3 Akshita Poonia #13 Ankita Parulekar #18 Rajashekar Reddy
Introduction to Custom Error Handling • When an error occurs in an ASP. NET application an exception is thrown • If the exception is not handled by the application, an ASP. NET server Error page is displayed. • This page includes an error message, a portion of source code that threw the unhandled exception, and other debugging information. • These pages are not understandable by the user, so a more generic and custom error page is displayed to the user using exception handlers.
How to handle back button problem. • Suppose user adds 2 items in his shopping cart • Then he decides to delete one item from the cart • In the meantime he clicks the back button where in cache memory the older page is saved where he has 2 items. • If he clicks the checkout button now the user thinks he has 2 items in his cart, but he will be paying up for only one item.
• Two ways to handle back button problem ØTry to prevent pages from being saved in browser’s cache. So that when the users clicks the back button old page cannot be retrieved. ØThe other way is to code the critical web form, so they detect when the user attempts to post that isn't current. To do that a form can use timestamps or random numbers to track the use of pages.
How to disable browser page caching
How to use timestamps to avoid the backbutton problem
How to get and use Exception Object for an error • In order to get and use error details, use properties and methods of the Exception and Http. Server. Utility classes. • Use try, catch and final to get exception object. Try clause throws exception, Catch clause catches the exception, then finally redirects to final block if the exception is not handled in the catch block. • To use the Exception object in Page_Error procedure, use Get. Last. Error method of the server object, which is accessed using server property of the page.
How to get and use Exception Object for an error • Using the Application_Error procedure of the global. asax file, this procedure is executed if an exception is not handled by any exception procedures including Page_Error Procedure. • Get. Last. Error of the Page_Error procedure does not return original exception. It returns the Http. Unhandled. Exception exception. • In order to get the original exception of the Get. Last. Error method use Inner. Exception property of the Exception object.
Introduction to Deployment 3 Ways to deploy ASP. NET application 1. DOS XCopy command 2. One click publish 3. Set up program
Xcopy Deployment
One Click Deployment
Set-up Program for Deployment
Thank you
- Slides: 23