ASP.NET - How to fix.PageRequestManagerParserErrorException

Asked By anbu n on 02-May-11 06:57 AM
Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Details: Error parsing near '.</H1></Body></Html>'.
Source File: http://www.binarch.info/Multiply/Amada/ScriptResource.axd?d=tCtAs1H5i5sYpJmoFfPPoJ1AdwRZ1A5b_MPoyQ-0aWLgfuE_sU82WfTM0h1LYeAuO6MzswjEyIaaJE2h_7dc_zTKIukaugav-u00hpXhfdDxgZLs2Lb7Y5uNQf124MtO0&t=7f5e5dbc

-----------------------
The above error occurs very rarely ... if this error occurs ... i have to
 re enter the values / datas which works but the previous values enters don t work . is this error caused by update panel or stored proc or ?

Riley K replied to anbu n on 02-May-11 07:03 AM
At the page include
     <%@ Page EnableEventValidation="false" %>

The event validation mechanism reduces the risk of unauthorized postback requests and callbacks. When the EnableEventValidation property is set to true, ASP.NET allows only the events that can be raised by the control during a postback request or callback.
Jitendra Faye replied to anbu n on 02-May-11 07:04 AM

There is an excellent blog entry by Eilon Lipton. It contains of lot of tips how to void this error:

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

Read the comments too. There is a comment of somebody with the same problem: "I solved it changing server idle time of my app pool on IIS. It was only 5, so I incremented it and now works."

"The UpdatePanel control uses asynchronous postbacks to control which parts of the page get rendered. It does this using a whole bunch of JavaScript on the client and a whole bunch of C# on the server.

Asynchronous postbacks are exactly the same as regular postbacks except for one important thing: the rendering. Asynchronous postbacks go through the same life cycles events as regular pages (this is a question I get asked often).

Only at the render phase do things get different. We capture the rendering of only the UpdatePanels that we care about and send it down to the client using a special format. In addition, we send out some other pieces of information, such as the page title, hidden form values, the form action URL, and lists of scripts."

Most common reasons for that error:

  1. Calls to Response.Write():
  2. Response filters
  3. HttpModules
  4. Server trace is enabled
  5. Calls to Server.Transfer()
For more detail follow this-
http://stackoverflow.com/questions/290121/asp-net-ajax-error-sys-webforms-pagerequestmanagerparsererrorexception

Ravi S replied to anbu n on 02-May-11 07:05 AM
HI

This refers to the message receive from the server could not be parsed. Common cause for this error are when the response is modified by call to Response.Write(), response filters, HttpModules, or server trace is enabled.
TSN ... replied to anbu n on 02-May-11 07:06 AM
Hi..

THis article provides the ways to solve this error...

How do I avoid getting a PageRequestManagerParserErrorException?

To start with, don't do anything from the preceding list! Here's a matching list of how to avoid a given error (when possible):

  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.