Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Ajax Error: Sys.WebForms.PageRequestManagerParserErrorException

Tags:

My website has been giving me intermittent errors when trying to perform any Ajax activities. The message I get is

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 '  <!DOCTYPE html P'. 

So its obviously some sort of server timeout or the server's just returning back mangled garbage. This generally, unfortunately not always, happe

like image 829
Phil Bennett Avatar asked Nov 14 '08 13:11

Phil Bennett


2 Answers

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

Sys.WebForms.PageRequestManagerParserErrorException - what it is and how to avoid it

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()
like image 92
splattne Avatar answered Sep 21 '22 18:09

splattne


Probably there is an error occuring on post back. In this case, you can view the details about the error by adding a PostBackTrigger to your updatepanel and referencing the button which causes the problem:

    <asp:updatepanel ID="updatepanel1" runat="server">         <Triggers>             <asp:PostBackTrigger ControlID="button1" />          </Triggers>         <ContentTemplate>          </ContentTemplate>     </asp:updatepanel> 
like image 43
CSharper Avatar answered Sep 21 '22 18:09

CSharper