Asp.net ajax is widely used in a recent project. In the asynchronous update mode of UpdatePanel, exceptions in background processing do not cause changes to the client interface, instead, the exception information is directly displayed in alert mode, so I stole a lazy and detected non-conforming input in the background, just throw the error message. But now the problem is found. In this way, how can we handle other unprocessed exceptions?
In order not to modify them all again, I have considered these methods:
1. In customErrors configuration of web. config, set to go to the specified page when an unhandled exception occurs;
2. In the Application_Error event handler of Global. asax, output the exception information to the specified page and display it to the client;
3. because all my pages inherit from a MyPage class (and it inherits from the System. web. UI. page), so you can also consider in the Page_Error event processing program of MyPage to output the exception information to the specified Page and display it to the client.
However, the first and third methods directly go to the specified page when an exception occurs, so as to not achieve the direct alert error prompt effect. The second method, however, this asynchronous program does not handle exceptions and does not redirect pages, but Server is used in Application_Error. the exceptions captured by the GetLastError () method are often not the ones that directly contain the friendly error information, but the exceptions caused by the GetLastError () method. web. httpUnhandledException is abnormal. Therefore, this method is not ideal.
Therefore, I want to discuss with the experts in the garden how to handle other unprocessed exceptions (such as Page_Load) while taking advantage of the convenience of Asp.net ajax exception handling! IsPostBack code ).