ASP.NET Ajax Error: Sys.WebForms.PageRequestManagerParserErrorException

后端 未结 15 688
轻奢々
轻奢々 2020-12-05 18:20

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

Sys.WebForms.PageRequestManagerP         


        
相关标签:
15条回答
  • 2020-12-05 18:56

    In our case the issue was caused by a rewriting proxy on the way. The rewrite modified the content of the update panel response. But this response also contains original size. The rewriting mechanism cannot know that few bytes of the response actually contains original response size and it should also be modified.

    The update panel response starts like this:

    1|#||4|30502|updatePanel|pnlUpdate| ...
    

    The 30502 is original size of the content which is being updated. Rewriting engine modifies the output, but the size stays unchanged => parser error exception.

    I don't see a way how to overcome this issue from the client side. We would need to know how exactly was the content modified and then somehow change the size in the response before UpdatePanel ClientScript starts processing it.

    0 讨论(0)
  • 2020-12-05 18:58

    I solved this exact same problem removing the Content-Type: form the Custom HTTP Headers section in the HTTP Headers tab in IIS. This was breaking the encoding of the page and somehow it affected Ajax in general.

    The Content-Type I had configured in IIS was setting the encoding to ISO-8859-1.

    0 讨论(0)
  • 2020-12-05 19:06

    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()
    0 讨论(0)
提交回复
热议问题