Posted by: Vijay Modi | April 13, 2007

Sys.WebForms.PageRequestManagerParserErrorException

passA partial-page update is initiated by a client request (an asynchronous postback) to the server. The server processes the request and returns a response to the client.  

If the browser does not receive a response in a specified time, the    Sys.WebForms.PageRequestManagerTimeoutException is raised. To change the interval that elapses before asynchronous postbacks time out, set the AsyncPostBackTimeout property of the ScriptManager control.    

If an error occurs on the server while the request is being processed, an error response is returned to the browser and the Sys.WebForms.PageRequestManagerServerErrorException exception is raised. To customize error handling and to display more information about the server error, handle the AsyncPostBackError event and use the AsyncPostBackErrorMessage and AllowCustomErrorsRedirect properties. For an example of how to provide custom error handling during partial-page updates, see Customizing Error Handling for UpdatePanel Controls.  

If the response to an asynchronous postback returns without an error but there is an error processing the response in the client, the Sys.WebForms.PageRequestManagerParserErrorException is raised. For information about how to handle this error condition, see ASP.NET AJAX Debugging and Tracing Overview.    

How to avoid this problem: 

1. Calls to Response.Write():
Place an <asp:Label> or similar control on your page and set its Text property. The added benefit is that your pages will be valid HTML. When using Response.Write() you typically end up with pages that contain invalid markup.

2. Response filters:
The fix might just be to not use the filter. They’re not used very often anyway. If possible, filter things at the control level and not at the response level.

3. HttpModules:
Same as response filters.

4. Server trace is enabled:
Use some other form of tracing, such as writing to a log file, the Windows event log, or a custom mechanism.

5. Calls to Server.Transfer():
I’m not really sure why people use Server.Transfer() at all. Perhaps it’s a legacy thing from Classic ASP. I’d suggest using Response.Redirect() with query string parameters or cross-page posting.

Another way to avoid the parse error is to do a regular postback instead of an asynchronous postback. For example, if you have a button that absolutely must do a Server.Transfer(), make it do regular postbacks. There are a number of ways of doing this:

1. The easiest is to simply place the button outside of any UpdatePanels. Unfortunately the layout of your page might not allow for this.
2. Add a PostBackTrigger to your UpdatePanel that points at the button. This works great if the button is declared statically through markup on the page.
3. Call ScriptManager.RegisterPostBackControl() and pass in the button in question. This is the best solution for controls that are added dynamically, such as those inside a repeating template.

Support: http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx#1820815

Hope it will resolve this problem. You can add your comments here.

Regards,
Vijay Modi

Responses

This problem also occurs very specifically with update panels when setting session variables. The website thread I linked has a solution to this problem. The difference between the problem linked and problem here is the absence of the methods you listed being used with the same symptoms.

Hi,
I don’t know to wich categories this belongs but SmartNavigation=”true” seems to cause also a “Sys.WebForms.PageRequestManagerParserErrorException”.

Just some tip if you looking for hours just as I did ;)

Grtz

The new URL to the ASP.NET AJAX Website article about debugging and tracing :

http://ajax.asp.net/docs/overview/ASPNETAJAXDebuggingAndTracingOverview.aspx

Check your firewall settings too!

Solution Posted On Telerik Blogs

That is some nice information on how to avoid the error. However, sometimes, this error may be absolutely unavoidable. For example, suppose the case where an Ajax partial-post calls to a database and suppose the database is offline due to a reboot. In such a case, the modal popup will appear in IE to the enduser, who must dismiss it. Furthermore, such popups will stack, such as when the Ajax calls are frequent, such as in a chat application’s polling. My question is– what can be done to CATCH the error, avoid the modal message box stacking, and redirect to show a generic error page? Please advise. Thank you. — Mark Kamoski

I find i only get the error when i have dynamically generated the controls. If i hard code the controls into the aspx page, i don’t get it. If i dynamically generate the controls in the code page then i get the problem on the whole page. I don’t know the answer but maybe this helps.

Can someone give me a tip for this problem?:
I have textbox with user login, button “OK” and updatePanel with label (error messages).
I change login, hit “OK”. Server checks, if changed login is available (must be unique).
- if no, error is shown /* { lblError.Visible=true; updPnlError.Update() } */ - THIS WORKS FINE
- if login is available, i save change and than I WANT TO REDIRECT TO ANOTHER PAGE - How can i do that?? (In (STUPID) IE7, Server.Transfer() and Response.Redirect() don’t work - both shows the PageRequestManagerParserErrorException)
Thx..

Leave a response

Your response:

Categories