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.


Have you ever got this kind of error when you are doing an Async postback using AJAX.NET (starting from Beta 2 if I’m not mistaken and going all the way to the current RC1 – at least at the time of writing this post) ?

It seems the newer versions of AJAX.NET really hates having “Response.Write” being called while doing an Async postback. It changes the response a bit causing it a hard time extracting the changed values and updating the changes using JavaScript on the client side.

If you get this error go through your page and all the controls in it (including controls within controls) and make sure you don’t have a “Response.Write” in the markup page.

Having “Response.Write” in the code behind in an event that is fired on an Async postback like Page_Load, Page_Render or the handler that handles that exact event can cause the same problem.

If you must use “Response.Write” you can get a similar solution by using a Label control and update it instead of using “Response.Write“.

If you use “Response.Write” in markup pages (ASPX or ASCX) replace them with either the “=” syntax (<% = MyProperty %>) or use the same solution mentioned above, adding a Label control and updating it in the code behind.

  • andre joseph

    I have a user control that uses response.binary write. I need an updateprogress control to let the user know when the files are being process until the files are presented to be downloaded. Any suggestion on how to do this??? A label control can not help in this situation.

  • Andre, if I understand correctly, its a bit more complicated than that since you want to inform the user when you finish the response.binarywrite, is this correct?

    If you have a long running operation the best way to do that is using an async request, i.e. load a page, an async request will start the process itself. You might be able to flush updates as you go or update the status of the operation in a different place and send a request every X interval to a different URL that will check that same place.

    A good way to do that might be to write to a temp location the status of your job, querying it from a different URL with a certain ID can show you the status.

    Hope this helps.

  • Nikks

    Hi same problem occur to me also i am not using response.write but else i am to write on label
    and when i add asynchronouspostback in update panel for that event same error displayed again and again what should i hav to do
    error is System.Webform.pagerequestmanagerparseexception

  • Nikks

    I was getting this same error message and after doing some searching around I tried adding EnableEventValidation=”False” to the top of my .aspx and this stopped the error message for me.

  • Nikks, you can use a Label Control or a Literal Control (which allows you to even put HTML, if I’m not mistaken). That way you can set the value of these control in the code behind and not use Response.Write that freaks out UpdatePanels.

  • Gan

    Eran Thank you very much

  • A.Ghazal

    I have the same problem and solved by placing the Button which contains response.redirect outside the updatepanel.
    Hoping that might help others.

  • Kledi

    Thank you very much. this has solved my problem.

  • Bhaskar Joardar

    Thanks Eran for the post. I have a different kind of problem. I’ve hosted my application in a 2003 server(32 bit) and having this error message.
    When I hosted this application in a different 2003 server (64 bit) the error message is not appearing. This arror message is not appearing too when I amrunning the application from development environment. Is there something I need to change in server configuration? Please respond.

  • Bhaskar Joardar, you might some httpModule or ISAPI filter install on that machine that causes the output to be changed a little bit, which may cause this issue.

  • Pushkar

    i just added a trigger and it worked fine

  • Pallavi

    I am creating a html file, and writing to it on click of a button. The button is a html button and i am assigning a server buttons click event to it for doing a postback. when i click the button i get this error

    Message: 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 ‘<script language='ja'.
    Line: 4723
    Char: 21
    Code: 0
    URI: http://localhost/Rock/ScriptResource.axd?d=t1k5m-O7kOjzqadifkdy713TRyeSFi06P_m-MGrCaRFeZNoTtp9uy0CuP4YpasyOnsPvK67oZv_VwqcV-EuxA0hgwKWPxXhaelGCOiO9VRM1&t=53928ded

    Please help me!

  • Have you tried doing one of the suggested items in the post and in the comments? It usually fixes the problem.

  • Mathewmmathew-nest

    Problem :

    Sys.WebForms.PageRequestManagerParserErrorException will occur when redirecting ur page ,lets say button click inside UpdatePanel in aspxAjax

    Soln :

    1. Add a “GoTo” button in ur aspx page where update panel is using and add it outside Update panel

    1a. In ur code assign ur just registered userID to session variable , say Session[“UseridJustregistered”]= Id from DB or UsernameField

    2. respose.redirect(“regSucces.aspx?urlid='”+Session[“UseridJustregistered”]+”‘”);

    3. Check if Session[“UseridJustregistered”] is null or not

    –> This is OLD Classic ASP way which can solve our problem , by the time microsoft find a solution we can tackle it this way <–

  • Pallavi

    Yes , I tried removing the Response.write in my page. But still the propblem persists. The session is getting expired after this action

  • Hi All,

    I have a aspx page, inside that page I am using 2 usercontrols. When we click a button in usercontrol1 , I just trigger a event to aspx page then from the aspx page I call a public function in usercontrol2 for display the items in usercontrol2. I have put entire aspx page inside a update panel (ie both usercontrols are inside the update panel).
    Its working fine in Loacal Machine. ie When we click a button in usercontrol1 it will display items in usercontrol2 without page refreshing. But when I uploaded this to live server its not working and I got a error. Please review and let me know your comments.
    site : http://www.maximumpublishers.com
    error : Webpage error details
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
    Timestamp: Wed, 2 Jan 2002 09:37:41 UTC

    Message: 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 ‘

    <meta http-equiv'.
    Line: 4723
    Char: 21
    Code: 0
    URI: http://www.maximumpublishers.com/maximumpb/ScriptResource.axd?d=AY-S7yTHSUN7z0i3jvwYiVOoOdLi8ZOP2VEH9tBX57YED3VK6QB_zzfknvo8uiduIdvgwCkvV277R6j9shB7s1DrxVs6Ov3eUv_v1jrYoM81&t=44aca1fe

  • Sameer Shah

    Thank you. This was a very important article. For me it was AJAX in which was causing problems.

  • Amazing, this problem continues. I have this issue in a data grid inside of an Ajax panel. The only time it happens is when the page sites for 20 minute (timeout) but still even though I know it hit the timeout window, I should not get this error on the client on a post-back. I do though have attribute.add on buttons inside of the panel to disable the button onclick.

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
    Timestamp: Fri, 22 Apr 2011 14:36:43 UTC

    Message: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
    Line: 938
    Char: 13
    Code: 0
    URI: http://localhost/SiteTest/ScriptResource.axd?d=gJPPy3_6ucsDrvIZ0MOHHO3Lh1NDaZFksGausRtZHorfpC9upVWUqPBOqQCc22MBXwXu2Gw4hlQdwC8iBdIY0LhrlpcHbQRRCl4WpJHcJvBkYb0IcOfqe3P79wXEjzpjGKmG7olTs-KPbKwP8tarHw2&t=ffffffffbd2983fc

  • chamila
  • SS

    Dear all
    I was getting same error system.webforms.pagerequestmanagerparseerrorexception..error parsing <!doctype html P'.now my web.config file is also not working.even if i am making new project.I dont knw it is corrupt or what.Do i need to reinstal it.Kindly hlp to resolve this issue.

    Thanks to alll
    Regards

  • Vishal Gilbile

    Thank you it solved my error

  • Wagnerpdasilva

    but i want redirect my page

  • Imtiaz Ali

    Perfect! its working for me

  • Chittaranjan_reddy

    but i did not Used response i just add new row to grid view

  • Gilaziv1

    by Response.write i open txt file. how can i do it with Label coontrol?
    this is my code:
    path = HttpUtility.UrlPathEncode(txtFileExportName.Text + “.txt”);
    Response.Clear();
    Response.AddHeader(“Content-Disposition”, “attachment;filename=”” + path + “””);
    Response.Charset = “”;
    Response.ContentEncoding = Encoding.GetEncoding(“utf-8”);
    Response.Write(XMLContent);
    Response.End();
    thanks

  • In your case it seems that your code doesn’t need the ASP.NET WebForm, only a request handler which returns the response.

    I suggest implementing this via a RequestHandler.

  • Gilaziv1

    thanks for your answer. Can u explain more , or bring me example?My case is:
    i have page, within it there is usercontrol wrapped by update panel, and one of the things i am doing in the userControl is the response.write above.

    thanks

  • Put a Label control inside the UpdatePanel.
    Instead of doing response.write with the output of the file, set the XMLContent as the value of the label control.

  • Gilaziv1

    i have the solution:
    in the user control i put also update panel and added PostBackTrigger for the button which do the code of response.write opening file.

    thanks

  • dude_id

    This is working!!! Thankyou Thankyou Thankyou

  • Yogesh

    I am doing response.write to open a file from the ShowSelectButton=”True” in the gridview. I have already added AutoPostBackTrigger for the gridview.But it is still showing the error.