How to fix Sys.WebForms.PageRequestManagerParserErrorException in AJAX 1.0

Last year I wrote a fix for AJAX 1.0 on my old blog, looks like many people found it helpful, I wanted to make sure people understood that issue only happened with ASP.NET AJAX 1.0. I cannot reproduce the same problem with AJAX 3.5.

You will encounter this issue when mixing callbacks and postbacks, as callbacks do not use Response.Write and there is not complete Requests to the server.

This is a bug on the MS ASP.NET 2.0 AJAX 1.0, is not that you are doing something wrong, the framework cannot handle the request validation and the exception is thrown. I found that you can catch the exception using the Script manager; information about it here: http://alpascual.com/blog/al/archive/2007/03/26/Code-Snip-_2200_Customizing-ScriptManager_2200_-to-detect-errors.aspx

Or better yet, you can disable the error by disabling the request validation. On top of the webform add: enableEventValidation="false"

UPDATE: setting enableEventValidation does not fix the problem in all the cases. The problem can be cause with a timer in your application as well.

Cheers

Al

Read it here

30 Comments

  • Plz send me solution for this error

  • This solution is worthless, pasted all across the net, and worthless

  • i am also facing the same problem. please some expert must help us.

  • i agree with Mr Dave
    (Monday, November 10, 2008 1:44 AM by Dave)

    actually i tried all this things. but still getting error.
    at local it works fine. but after deploying at godday acocount it isn't work :(

  • I resolve my error using response.redirect instead of server.transfer /*works in my scenario*/

  • Yes.. i have also resolve my error using Response.redirect instead of server.transfer

  • I get this error by just making repeated calls to an update panel, or when the session times out, even if the session isn't being used.

    What the heck is up with this?!

  • when search network is not found then generate this error in browser.

  • I tried your solution.....dint worked for me.....any other possibility?

  • Ususally I'm able to convert a SqlDataSource to a DataView to bind to a new Gridview use Response.Write to send the Excel file to the user using StringWriter, triggered by an asp:button. Trying from a button in the UpdatePanel is not working even with enableEventValidation="false" and I still don't see how to do this after reading this whole thread and posts, that is without trying to decrypting the blob of data AJAX receives from the server.

    Any tricks for me, or do I have to give up and move the button outside the update panel even though I don't want to in the layout?

    ~~~~~~~~
    'VB Sub

    Protected Sub btnDownload_Click(ByVal sender As Object, ByVal e As System.EventArgs)

    Dim sbFile as string = Now.ToString("yyyy-MM-dd").ToString( + ".xls"))

    Dim dv As DataView = mySqlDataSource.Select(DataSourceSelectArguments.Empty)

    DataViewToExcel(dv, sbFile.ToString)

    End Sub

    //C# Class void

    public static void DataViewToExcel(DataView dv, string filename)
    {

    //Convert SqlDataSource to DataView then export to excel for raw data without GridView formatting.


    if (dv.Count > 0)
    {
    if (dv.Count < 65536)
    {
    //VerifyRenderingInServerForm(gv);
    HttpContext.Current.Response.Clear();
    HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1");
    HttpContext.Current.Response.Charset = "";
    HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + filename.ToString());
    System.IO.StringWriter TextWriter = new System.IO.StringWriter();
    HttpContext.Current.Response.ContentType = "application/vnd.xls";
    System.IO.StringWriter stringwrite = new System.IO.StringWriter();
    HtmlTextWriter htmlwrite = new HtmlTextWriter(stringwrite);
    GridView gv = new GridView();
    gv.DataSource = dv;
    gv.AllowPaging = false;
    gv.AllowSorting = false;
    gv.DataBind();
    gv.RenderControl(htmlwrite);
    HttpContext.Current.Response.Write(stringwrite.ToString());
    HttpContext.Current.Response.End();
    }
    else
    {
    //Msg.Text = "Too many rows - Export to Excel not possible";
    }
    }
    }

  • Adding a trigger to the update panel outside the contenttemplate fixed my exel download from a button within the panel!

    Thanks to Jonny Coder!
    http://johnnycoder.com/blog/2008/07/25/export-gridview-to-excel-within-an-updatepanel/

    ...





    ...

  • a possible solution: Disable output caching for pages. I had output caching enabled for .ASCX files. That causes the problem.

  • I resolved this setting EnableEventValidation="false" .

  • 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 PUB'.

  • Thanks Sharanya.... the EnablePartialRendering="false" worked great and saved me a ton of testing.

  • I see this error with some of my users and I'm curious if the fix is some modification to the config on the server, why don't I have the issue with all of my users. Only a few PC's run into this problem while others have never experienced it. Is the real issue some incompatibility with software on the client?

  • Extracted from Comments and it is worked for me properly.

  • Hi,

    I have faced this issue when i was going to click on 'select link button' in a GV.
    Solution is :
    we need to Register that GV like...

    ((ScriptManager)this.Master.FindControl("ScriptManager").RegisterpostBackControl(GV).

    I hope this will help you.

    Regards
    Penchal Das(Ponguru)

  • Thanks to Jonny Coder!
    It works super !

  • I read this article throughout and modified my code from Server.Transfer to Response.Redirect and it solved my problem. It is working perfectly now :)

    Thanks to everyone !!!

    Ankit Jindal(@j)

  • it work for me ,thanks

  • Thanks.. Its working fine..

  • Please help us in avoiding this erro

    Microsoft JScript runtime 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 ' '.

  • Bed6pg I really liked your article.Thanks Again. Great.

  • 9xWleN Fantastic article.Thanks Again. Really Cool.

  • yZfia2 Major thanks for the article post.Much thanks again.

  • QZJPnb Appreciate you sharing, great article post.Much thanks again. Will read on...

  • Ajax is handy but maybe you want to take a look of JQuery.com
    Hope this help

    Alex
    Your nearshore partner for Outsourcing & Mobile Apps | 10 successfully years in software development.

  • Wow! Truely gleamed a tremendous amount of data from your blog. Thanks for the hard material.

  • 57DZ3o Thanks for sharing, this is a fantastic blog article. Really Cool.

Comments have been disabled for this content.