Previously, I defined Web. the customerror segment of config enables the system to go to the custom error page once an exception occurs. However, there is a serious problem, that is, the exception information cannot be seen, recently, I have become unable to accept this, so I switched to global. in asax, you can customize the application_error event to obtain the exception information here, pass it to the error page, and finally use server. the transfer method is redirected to the error page.
Server is used. transfer is not only for efficiency considerations, but also because it does not display the URL of the error page, it still displays the URL of the page that throws an exception, which is good, in addition, you can directly refresh the page during development to update the original page. unfortunately, it is not always valid. In some cases, the page that throws an exception is not directed to the error page, but shows a script error:
SYS. webforms. pagerequestmanagerparsererrorexception: the message was Ed from the server cocould not be parsed. common causes for this error are when the response is modified by cballs to response. write (), response filters, httpmodules, or server trace is enabled.
Details: Error parsing near'
<! Doctype HTML P '.
This error is beyond my understanding, so I turned to Google and found this article: No, you cannot call server. transfer on an ASP. net Ajax enabled page. As a result, you can understand that updatepanel is not used for pages without errors. This error is reported for all pages that use updatepanel. Cause of error: some sending replies are always caused by the client's pagerequestmanager object. It waits for the server to give a response and refreshes the page dynamically, but the server is used. after transfer, the server will send back the content of another page. This is not what pagerequestmanager thinks it should see, so it will generate a parse error, and of course server. transfer becomes invalid.
The solution is simple. Use response. Redirect.
By the way, if I handle exceptions in application_error and go to a fixed error page, the application_error event must be specially processed on the error page, because once an exception occurs on this error page, an endless loop will be formed, which will quickly write a large amount of junk data to IIS logs, the entire server is down until it is full of hard disks.