Server. Transfer conflicts with some sending back (Ajax)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.