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.
Asp.net exception handling method for ajax data