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

If you've used the Microsoft ASP.NET AJAX UpdatePanel control, there's a good chance you've hit the "Sys.WebForms.PageRequestManagerParserErrorException" error.

What's a PageRequestManagerParserErrorException?

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.

As I mentioned, this is rendered out using a special format that the JavaScript on the client can understand. If you mess with the format by rendering things outside of the render phase of the page, the format will be messed up. Perhaps the most common way to do this is to call Response.Write() during Page's Load event, which is something that page developers often do for debugging purposes.

The client ends up receiving a blob of data that it can't parse, so it gives up and shows you a PageRequestManagerParserErrorException. Here's an example of what the message contains:

---------------------------
Microsoft Internet Explorer
---------------------------
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 'Hello, World!106|upd'.
---------------------------
OK  
---------------------------

If you ask me, this error message is not all that bad. After all, I'm the one that made it :) The details indicate what was being parsed when it decided to give up. You can see the part of the text from my Response.Write(), and immediately after that is part of the special format I keep mentioning.

Why do I keeping getting a PageRequestManagerParserErrorException?

Well, chances are you're doing one of the things mentioned in the error message. Here are the most common reasons and why they don't work:

  1. Calls to Response.Write():
    By calling Response.Write() directly you are bypassing the normal rendering mechanism of ASP.NET controls. The bits you write are going straight out to the client without further processing (well, mostly...). This means that UpdatePanel can't encode the data in its special format.
  2. Response filters:
    Similar to Response.Write(), response filters can change the rendering in such a way that the UpdatePanel won't know.
  3. HttpModules:
    Again, the same deal as Response.Write() and response filters.
  4. Server trace is enabled:
    If I were going to implement trace again, I'd do it differently. Trace is effectively written out using Response.Write(), and as such messes up the special format that we use for UpdatePanel.
  5. Calls to Server.Transfer():
    Unfortunately, there's no way to detect that Server.Transfer() was called. This means that UpdatePanel can't do anything intelligent when someone calls Server.Transfer(). The response sent back to the client is the HTML markup from the page to which you transferred. Since its HTML and not the special format, it can't be parsed, and you get the 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.

Summary

I hope I've answered a lot of questions here and not angered too many of you. We're looking at ways to improve some of these situations in the next version of ASP.NET, but of course there are no guarantees. If you avoid changing the response stream, you're good to go. If you absolutely must change the response stream, simply don't do asynchronous postbacks.

 

Published Monday, February 26, 2007 6:00 PM by Eilon
Filed under: , , ,

Comments

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

Tuesday, February 27, 2007 4:27 AM by Atit

Can u get me..information on known AJAX ASP.net RC1 bug.

Description.

 For IE7, click on any asp:imagebutton on  extreme top or left corners that initates postback.

You will get System.Format exception becuase IE7 passes ImageClickEventArgs e  values wrong

e.X=NaN

and e.Y=-1

so e.x creates parsing exception.

Note:It works perfectly in firefox.It occurs in IE7 and IE6.

Atit.

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

Tuesday, February 27, 2007 4:51 AM by Mike

You forgot the bug in the role provider. It's on the asp.net forums, some people have to disable caching roles in cookies to avoid the error. It seems that the role provider adds the cookie to the response when it's too late.

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

Tuesday, February 27, 2007 8:58 AM by Dominick

I'm getting that error right now. I have an update panel with a wizard control inside. On a step I have a button that changes the text of a textbox. Before I click the button I can navigate to any step just fine, but I get that error on the first step navigation click after I click the button that adds the text. It doesn't happen every time though. Very strange. The message says the error occurs at:

'able>

| <HTML>

<Head>

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

Tuesday, February 27, 2007 1:41 PM by Eilon

Atit,

To submit bug reports, please use Microsoft Connect.

Mike,

Yup, that's another case where it doesn't work. I believe that bug will be fixed in the next release of ASP.NET AJAX.

Dominick,

I'm not sure what's happening there. Do you have anything using output caching? It looks like some component on the page is rendering out some additional markup that shouldn't be there.

- Eilon

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

Wednesday, February 28, 2007 3:54 AM by Atit

Eilon,

  Rendered HTML markup is same as for firefox.

Again, I am not using any output caching.

You can simply reproduce by creating new AJAX asp.net website with just simple page.

Take imagebutton that initates postback in asp:updatepanel.

Click on extreme top or left corners.You can easily get exception in ie7.

Atit

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

Wednesday, February 28, 2007 1:26 PM by Eilon

Atit,

I'm sure the bug repros, but you'll need to file the issue on the Microsoft Connect web site that I linked to. This is just my little old blog, not a bug reporting site :)

- Eilon

# Proper Handling when this error does occur?

Thursday, March 01, 2007 12:27 PM by Alan

This error can easily appear when the session has timed out while the user's page was idle.

Can you post a link to a site describing how best to handle this error when it occurs?  While the error message might be beautiful to a developer, it's not at all to an end-user...

Alan

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

Friday, March 02, 2007 9:49 AM by jim

At my company we have just begun experiencing a problem when using UpdatePanels with Response Filters after upgrading to the release version of atlas. We have multiple clients running within the same environment and we give them the ability at runtime to customize certain business terms like "Supplier" to match their internal usage. Rather than ever directly use the term Supplier, we use a token [$Supplier$], then each client can customize that token to match what they use internally: Supplier, Vendor, Distributor, Partner, etc. These tokens are used throughout the application: in aspx pages, in c# code, inside text stored in the database. Replacement terms are stored in the database and are modifiable through the web interface at runtime by the clients themselves. The solution we came up with to allow dynamic on the fly replacement of tokens regardless of where they came from was a Response filter. Essentially we just run a regex on the response, swapping out tokens for the replacements configured by the client that the current user is associated with. ASP.NET localization doesn't help us because the clients want the ability to change the tokens at runtime via the frontend.

In the previous version of atlas that we were using the response filter caused us no problem.  After upgrading to the release version of atlas however, we must either disable partial rendering in the script manager tag (basically stop using update panels) or disable the token replacement filter (not an option).

Do you have any recommendations or workarounds? Will this limitation where update panels do not work with Response filters be addressed in a future version of atlas?

--jim

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

Friday, March 02, 2007 12:36 PM by Andres

Eilon,

I have the same problem that Dominick has.

No Response.Write

No Output Caching

No Response Filters

No Trace

No Http Module

No Server.Transfer

Just an ImageButton in a GridView and Nested Master Pages.

The ImageButton click only hide the GridView an show a Wizard.

The error doesn't happen every time.

Andres

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

Friday, March 02, 2007 1:19 PM by Eilon

Alan,

The error can be handled by using the PageRequestManager's endRequest event. However, I highly recommend you think twice before doing that. The error really shouldn't be intermittent, and I'm not sure why people are seeing that. The error usually indicates a problem with the page, and should not be ignored. If you do handle the error it should be to log it to some admin error database for further analysis.

jim,

I don't think that's the best usage for a response filter. Instead, I'd recommend using using something like an expression builder or other type of code snippet to handle it dynamically. We're looking at what it might take to support response filters during async postbacks, but it's unlikely that we will be able to handle it. The older CTPs did support it, but at the expense of many other pieces of functionality.

Andres,

As I mentioned just above, I'm not sure why the error would happen intermittently. If you can show me a simple repro then I can take a look at it to investigate.

- Eilon

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

Friday, March 02, 2007 2:34 PM by Shaggy

I have a page that has worked fine up until today, and I haven't changed any code or html in the page since it last worked without error.

Situation is this...2 update panels; top panel contains 2 DropDownLists, 3 LinkButtons and 3 ImageButtons. It's a drill-down scenario where user selects option from DDL 1, then DDL2 is made visible and loaded with options. At that point, the 3 LinkButtons are made visible for selecting. Once a LinkButton is selected, the requested data is loaded and displayed in a GridView residing in UpdatePanel #2. The 3 ImageButtons are then made visible to allow for printing or downloading the data or viewing help.

This scenario has worked fine for me for the last week, flawless even. Then today, out of nowhere, it began throwing the ParserErrorException. It does this everytime I load the page for the first time in a session. I can select from the first DropDownList, then the second is displayed and loaded with options. As soon as I select select an option to trigger postback and retrieval of data, the error is thrown.

If I then view another page, then return to the affected page, it works without problem under all scenarios. This is very strange to me and I'm having a hard time isolating the cause. The controls I mentioned are the only ones on the page, other than some text and a few labels and divs.

Does this make any sense and can you think of anything I might look into for the source of the problem? Nowhere am I using any of the "known" problematic scenarios such as Response.Write(), etc...

Many thanks...

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

Friday, March 02, 2007 2:51 PM by Eilon

Shaggy,

The parser error will indicate where the failure occured in the response text. Does it give any hint as to where the problem is? Usually you'll see some text there and be able to figure out who generated that text and using what mechanism. In the example error I showed in the original post, I'd look throughout my source code to find where I'm rendering "Hello, World!". If I do that and see that it's the Response.Write(), I know that's the problem.

- Eilon

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

Saturday, March 03, 2007 10:00 AM by Shaggy

If only it were that simple...the parser error displays some html content that I cannot even locate in my code. It shows:

Details: Error parsing near '     </div>

    |<html>

 <head>

'.

I can't find that series of content anywhere in my code or html for this page. The only place a "|" is used is in a footer control that's part of the master page, but that character is not sitting beside any html tags, that's for certain.

I previously thought it was happening the first time it was run for any new session. I was mistaken though, it actually only does it once per server instance. When debugging, I have to kill the server in my task manager and restart the project for the bug to reappear. Does this suggest that once in production, it's likely that I could just load the site, hit this problem page once and then nobody else would see the error?

- Shaggy

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

Saturday, March 03, 2007 3:28 PM by Eilon

Shaggy,

The pipe "|" is part of the UpdatePanel response format, so it wouldn't appear in your code. However, something is definitely odd here. It looks like is rendering out the </div> before the <html> even begins, which is very odd. On the other hand, nothing should be rendering out the <html> or <head> tags since they shouldn't inside an UpdatePanel either. I'd suggest starting with a new, blank page that works fine, and then gradually add parts to it until you find out which one does not work.

- Eilon

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

Sunday, March 04, 2007 12:55 AM by Shaggy

Well, the problem miraculously went away once published. After publishing it, I immediately viewed the page and it did not throw any errors for me and has worked fine since. I guess it's possible that someone beat me to the initial page view, but if so, no big deal as it seems to be working well now. I still get the problem locally though. I guess I will try to rebuild it when I have time to see if I can figure out where it goes wacky.

Feel free to see the results at www.eastmarietta.com/schedules.aspx.

Thanks for all the insight...

- Shaggy

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

Wednesday, March 07, 2007 1:28 PM by Doug

You can use Server.Transfer if you pass 'false' in the second parameter.

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

Wednesday, March 07, 2007 5:54 PM by Mark

Hi all,

I am seeing this problem only when I publish my website, and oddly enough when using an ImageButton outside of the UpdatePanel (registered as a trigger) too. The UpdatePanel contains a single WebUserControl, which is dynamically loaded in code-behind. Is this perhaps a bad idea? It works fine locally.. and there's no Respone.Writes et cetera. Comments anyone?

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

Wednesday, March 07, 2007 9:22 PM by Mark

Hi Eilon,

Thanks for making this post - it is definately helping! Can I ask you this though: If my updatepanels work perfectly on my local machine (both from within VS2005 AND the published version via IIS) but DON'T work up on the server, what else should I be looking for? Some pages work, but others don't, or don't render properly. I am even getting the odd timeout. Any ideas? I sold this project to my client because the AJAX stuff is so cool!

# re: Sys.WebForms.PageRequestManagerParserErrorException - intermittent

Thursday, March 08, 2007 12:51 PM by Greg B

Great info here, thanks, but I am not doing any of the common causes like Response.Write...

I only get the error on the first page load and it's always:

Details: Error parsing near '     </div>

   |<html>

<head>

I am using a MasterPage with an UpdatePanel around a GridView. Is there another solution to prevent this that was not mentioned here?

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

Thursday, March 08, 2007 4:25 PM by Leyla Ghassemi

 Hi Eilon,

I have a page that contains a viewform in side an update panel.  The Viewform allows the users to edit the information with in the view form.  The Edit Version of the form contains texts box’s labels and drop down lists.   what happens is when I start VS2005 and open my project and run my app (Debug mode), the first time that I click the Edit button I see the "Sys.WebForms.PageRequestManagerParserErrorException ", If I click the OK button and click the Edit button again I don't see the error. if I stop the debug session and start another debug session, and click the Edit button I don't see the error.  I see this error only the first time after I have started the VS2005. Can you tell me what I am doing wrong?

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

Thursday, March 08, 2007 7:20 PM by Mark

Hi Eilon,

Is there perhaps a way to 'encode' the ascx web user control HTML to prevent these parser errors?

Cheers, Mark

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

Thursday, March 08, 2007 8:24 PM by Mark

I've solved my PageRequestManagerParserErrorException errors (finally!)

Try enableEventValidation="false" on the ASPX page containing the UpdatePanel.

Note that my page had the ImageButtons initiating the UpdatePanel refresh outside the UpdatePanel, and that I declared an AsyncPostBackTrigger in the UpdatePanel for each ImageButton Click event.

I will include this advice on some of the other posts, as there are quite a few people having this problem I think.

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

Friday, March 09, 2007 12:08 AM by Keyur

Thanks its working fine.

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

Friday, March 09, 2007 3:39 AM by Fred

I have a similar situation to the one mentioned by Greg B.  The error only occurs on clicking a button on the first page load.  After dismissing the error message the error doesn't occur again.  (Occasionally the error doesn't occur the first time). The error details are similar (though not identical) to what he reports:

Details: Error parsing near '>

  |<html>

<head>

I too am not doing any of the common causes listed above.

The error doesn't occur when I set enableEventValidation="false", but this isn't recommended for security reasons.

I would much appreciate any feedback.

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

Sunday, March 11, 2007 5:39 PM by Ola

I get a weird "next-step-problem" with the UpdatePanel: On page "A", inside an update panel i have a GridView. In the GridView's RowCommand code

i have a Response.Redirect to page "B". This all works fine except; on page "B", in PageLoad i want to save a copy of Request.UrlReferrer, but it is now NULL. This only happens when the GridView is inside an update panel.

Any clues anyone?

Regards, Ola

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

Tuesday, March 13, 2007 11:10 AM by Lloyd

Eilon,  great information.  I thought I had solved this issue another way, in the case where there are multiple user controls on a rendered page, each with an update panel on it.  For instance, a navigation bar on the left, and a detail section with another update panel.  The error message I get is pointing to near the first UpdatePanel when a AsyncPostback happens in the second.  I thought it may be that I was lazy and left them as the default name and then were reffering to the wrong instance, but it happens when they are uniquely named. For now, I'm removing the UpdatePanel in the first UserControl, but it would be nice to have them wherever I felt like it. :)

Any idea would help.

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

Tuesday, March 13, 2007 1:40 PM by Dan Ehrig

Hi Eilon,

I know you already directed people to submit bug reports at microsoft connect, but I wasn't able to find a way to get permission to submit the bug.

Rama Krishna over in the ASP.Net forums discovered that this error can be caused by what is presumably a bug in the RoleManagerModule.  The bug appears to write the cookie into the response stream too late which screws the response up.  Here's the url to his post:

http://forums.asp.net/thread/1555817.aspx

Is there any way you could get this to the right people at MS to look at this bug?  It's causing a lot of us to have to turn page validation and role caching off, neither of which are good things.

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

Tuesday, March 13, 2007 7:53 PM by Simon

Hey guys,

A major possible reason is trying to set an initial session using the AJAX updatepanel.  This will result in one error, then no errors for ages unless you load another browser/clear cookies, etc.

Just call Session["blah"] = true; in your page load event.

This will create the cookie needed for the session variable to work, and therefore anything using a session will also work without throwing the error.

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

Tuesday, March 13, 2007 10:36 PM by Chris C.

w.r.t this post: http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx#1868485

I can't seem to be able to catch the error properly in the endRequest javascript event. I can catch any other sorts of Exceptions thrown by my code in that event handler on the client side, but this exception in particular doesn't get to the event handler. I'm also waiting on a sure fire way to get rid of this intermittent error message.

Any ideas ?

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

Wednesday, March 14, 2007 10:47 AM by Dan Ehrig

Eilon, thanks for your info on this.

I know you asked that bug reports be sent to Windows Connect, but I was unable to find a way to get permission to submit a bug report.

The other major cause of the Sys.WebForms.PageRequestManagerParserErrorException appears to be a bug in the RoleManagerModule.

Rama Krishna in the asp.net forums did a very good job of tracing the cause of this problem down but nobody from Microsoft has yet acknowledged its existence.  I'm sure this isn't your particular job at MS but do you think you could get it to the attention of someone who can do something about it?  The workaround leaves us with a choice of either forgoing event validation or forgoing role caching, neither of which is something I'd like to go without.

For Rama's detailed post on the subject please see:

http://forums.asp.net/thread/1555817.aspx

# Partial solution found

Tuesday, March 20, 2007 7:37 AM by siderite

 If you have to change the Response stream, here is a way to do it properly:

http://siderite.blogspot.com/2007/02/aspnet-ajax-and-responsewrite-or.html

Basically one deconstructs and reconstructs the ajaxy format.

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

Tuesday, March 20, 2007 1:48 PM by Chris

Just upgraded an application from RC1 to RTM 1.0 and started experiencing this problem.  

If it helps anybody, in my case it turned out to be http compression was turned on and it caused the update panel to raises the error.  Turned it off and voila, fixed.

PD: http compression is implemented in our home-cooked web framework by appending content-encoding header gzip/deflate values.

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

Saturday, March 24, 2007 9:02 PM by Joseph F

FYI, Server.Transfer doesn't cause to HTTP requests whereas Response.Redirect does. If you do a fiddler on it you will see it. The only reason to do a Server.Transfer is for transfering to a different page on the same domain.

The benefit is that it only does one HTTP request. Not that I use it... but I thought I would let you know.

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

Tuesday, March 27, 2007 11:23 AM by Stephen

I have a page with radio buttons inside an update panel, when one of them are selected and event is fired that hides certain panels based on which selection is made.  It works fine for everyone except when people go through the proxy server they get the error Sys.WebForms.PageRequestManagerParserErrorException  and the details say "<!DOCTYPE html P'."  Now on the page the P is the middle of the word public.

The page is using Master Pages

No Response.Write

No Server.Transfer

No Server Traces

No HTTP Modules

NO Response Filters

Any ideas?

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

Thursday, March 29, 2007 11:12 PM by Mark Walberg

This tip rocks. You saved me a bunch of work.

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

Monday, April 02, 2007 10:25 AM by Bret Williams

The enableEventValidation="false" tip fixed the error for us.   Luckily the page I put it on doesn't require any heavy security but I would like to see a fix for this bug as well as the session timeout bug, and last but not least on my Ajax wishlist the ability to completely suppress errors that get "alert'ed" to the user's screen.

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

Monday, April 02, 2007 12:44 PM by young

我还是没有看明白,由于session 过期这个问题时的处理方法。

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

Monday, April 02, 2007 1:07 PM by Brian

I have found out how to fix my issue with this showing up....

I have a theme with a css which was automaically being imported but I also had it on my master page.  It was showing up twice in the <head> of the source on the pages.  Once removed from the master page the error has went away.

# Another reason why you get the dreaded error: Unicode chars in the page source

Tuesday, April 03, 2007 2:18 PM by Siderite

 Let's say you cut an past some text from somewhere and it contains Unicode chars and you want to display it in a label. You will get the same error. Since HTML is UTF8, it should be an easy fix to override the page Render method and replace all Unicode chars with their &#[code]; HTML representation.

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

Wednesday, April 04, 2007 6:00 PM by Random

I really like the convenience of the in-page Trace output from the DefaultTraceListener, but yeah, the complete crash if it's used on a page with AJAX is a problem.  How difficult would it be to derive a class from DefaultTraceListener and somehow have it redirect it's output to a new browser window?

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

Monday, April 09, 2007 8:39 AM by remorknevets

I have an ajax-enabled webpage with a single updatepanel.  The site works great on my local development box, but when copied to the web server (that has ajax installed; using 'Publish Web Site' in VS 2005), I receive the following during a postback on that page:

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

I do not have any response.write()'s or anything else mentioned above that I can see.  I am using response.redirect("page.aspx") in buttons outside of the update panel, but I haven't read anything about that being an issue yet.  The update panel contains a textbox, listbox, and button (all aspx controls).  Any ideas?

Thanks!

# re: Session variables

Wednesday, April 11, 2007 4:17 PM by Jason

Thanks, Simon!  I have a user control in my update panel and this control modifies session variables;  adding a session variable in Page.Load fixed the problem.

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

Thursday, April 12, 2007 1:00 PM by Fernando

hi Eilon,

First of all thanks for the information you are posting... i'm having a problem related to this (i'm a newbie)... well i'm facing this error when trying to add a usercontrol to another usercontrol in runtime. Both are created programatically. I don't have put any of the possible causes to face this... Thanks in advance

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

Thursday, April 12, 2007 1:02 PM by Fernando

hi Eilon,

First of all thanks for the information you are posting... i'm having a problem related to this (i'm a newbie)... well i'm facing this error when trying to add a usercontrol to another usercontrol in runtime. Both are created programatically. I don't have put any of the possible causes to face this... Thanks in advance

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

Tuesday, April 17, 2007 7:54 AM by Karl

I am getting the error as well and like others I am not doing anything fancy with the responce stream.

here is the text of the 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 'br /><br />

</div>|<html>

   <head>

'.

Some of the other tricks do not seem to have worked thus far.  Error is inconsistant and will crop up on any page whether or not it has been viewed previously in the session.

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

Wednesday, April 18, 2007 1:19 PM by Neil

I am recieving this error regularly on the computers at the school I am working at currently (I can't seem to replicate it anywhere else but this is the place I need it to work because the site was written for them). It is giving up after the <!DOCTYPE html PUB point in my Master Page, I have tried removing the line to remove the error but it won't work properly without it. I have removed all of the <%= %> tags (which I know replicates itself as Response.Write() and replaced it with labels yet it still displays the error. The only way I can prevent the error is to completely remove the AJAX update panels which is not an option. Any other suggestions?

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

Thursday, April 19, 2007 4:20 AM by Andrei

Great article man! Solved the problem. Thanks.

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

Thursday, April 19, 2007 2:12 PM by Stephen

I have a gridview has three columns of buttons.  2 Columns take you to a new page and 1 column (which is why an update panel is required) changes the status of the record. Of the two columns that take you to new pages, 1 is just a normal gridview button column, and the other is a template with a repeater inside of it.  The repeater actually displays 6 buttons (or more depending on the categories in the database).  This all worked before I wrapped an update panel around it.  Now the repeater throws this PageRequestManagerParserErrorException and while the others work just fine.  None use response.write, though the repeater's event used server.transfer, which since I have had problems with update panels and server.transfers in the past I changed to response.redirect.  Any suggestions, the best I can come up with is that the update panel needs a reference to the repeater but since its basically a repeater inside a repeater I can't get the actual id's to the updatepanel (unless I do it on the server which I can get the id's of each repeater I just can't add them to the update panels list of triggers )

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

Thursday, April 19, 2007 5:06 PM by mauroivan

I put the attribute EnableEventValidation="false" and now works

I have an AsyncPostBackTrigger

fine thanks a lot Mark

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

Tuesday, April 24, 2007 11:12 AM by Brian

Here is a solution that I found:

Check your firewall settings to see if it is set to remove unknown headers.  If it is, change that setting so that it does not.  This fixed the problem for me.

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

Friday, May 04, 2007 4:51 PM by Gopi

I want to download a jpg image to the client on the update panel. If I cant use response.write(), then is there any other way to accomplish this

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

Wednesday, May 09, 2007 10:09 AM by jjbongo

Hi -

I have this exception occuring on several of my pages, in similar circumstances as Karl, Fred, Greg B etc.

I now believe it is related to this issue here:

http://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=7938

For me it only occurs on pages with controls which need to register javascript (contained in update panels) which are initially hidden, but after an asyncpostback become visible.

I was getting the message irregularly, till I started running it on a different server, now I get it consistently.

I haven't tried to solve the problem yet, I just wanted to share my thoughts.

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

Thursday, May 17, 2007 8:49 AM by jega
hi, when we use the application in outside of network this error will comming, whenever we send a request to server that time this error will occuring. " 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 " above post 2 persons are get solved 1. EnableEventValidation = "False", but this isn't recommended for security reasons. 2. Changes in Firewall Setting. Let me know, in Firewall what are changes we want to do for fix this problem. pls, give the result asap....

# PohEe.com | Sys.WebForms.PageRequestManagerParserErrorException @ MS Ajax

Pingback from  PohEe.com | Sys.WebForms.PageRequestManagerParserErrorException @ MS Ajax

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

Tuesday, May 22, 2007 9:15 AM by Lawrence
Hi, I don't know to wich categories this belongs but SmartNavigation="true" seems to cause also a “Sys.WebForms.PageRequestManagerParserErrorException” also. Just some tip if you looking for hours just as I did ;) Grtz

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

Thursday, May 24, 2007 10:04 AM by Jim

Referring to this message: Has the new release of AJAX come out that fixes the bug in the role provider?

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

Tuesday, February 27, 2007 1:41 PM by Eilon

Atit,

To submit bug reports, please use Microsoft Connect.

Mike,

Yup, that's another case where it doesn't work. I believe that bug will be fixed in the next release of ASP.NET AJAX.

Dominick,

I'm not sure what's happening there. Do you have anything using output caching? It looks like some component on the page is rendering out some additional markup that shouldn't be there.

- Eilon

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

Tuesday, May 29, 2007 5:19 AM by Phil
Hi Eilon, I had a similar problem to some of the above, I'd done everything recommended in your blog but was still getting the error. I had a look at the update panel response stream using :- args.get_response().get_responseData(); I noticed there was some error text at the end (Unable to serialize the session state etc..), which was related to me trying to insert a connection object into the session when the session state mode was 'SQLServer' (silly me). I'm assuming AJAX saw this as something trying modify the response stream and threw the 'Sys.WebForms.PageRequestManagerParserErrorException'. Hope this helps someone!

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

Wednesday, May 30, 2007 1:02 AM by Matthew Tester
I have the same issue as a lot of people with regards to the role provider and cookies causing the Sys.WebForms.PageRequestManagerParserErrorException. I'll add to the discussion that using the Fiddler tool was the easiest way to discover the error being returned. I could view the raw response coming back from the server and noticed the following error:

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

Monday, June 04, 2007 6:10 AM by Stevo
Hi guys, I'm working on a AJAX enabled Website and tested it in various browsers. A page using AJAX works fine in IE (what a surprise) in Firefox and Opera. It rises this error in Netscape, Mozilla, Seamonkey, mostly after 2-4 clicks. All browsers with latest version available. Unfortunately I can't check mac browsers. Why does asp.net AJAX work in some browsers and in the others it doesn't??

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

Tuesday, June 05, 2007 2:15 AM by vipul
i do not found any solution. i try out all givan solution. actually i want to export datagrid Data to excel.if u have any solution please post it.

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

Tuesday, June 05, 2007 8:26 AM by Eran Nachum
Great solution steps. You invited also to check out my weblog sometimes at: http://www.eranachum.com Thanks.

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

Tuesday, June 05, 2007 1:48 PM by Joyce
Thanks to Simon! I have a button & dropdownlist in an updatePanel that is setting a session variable upon postback. This was the first time I've seen this error. Adding Session("variable") = True fixed my problem. You Rock!

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

Thursday, June 07, 2007 10:19 AM by Jim Bonnie
Vipul, I had the same problem with a download to excel button. I resolved it by putting the button in the update panel and setting a trigger to force a full post back on the button.

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

Thursday, June 07, 2007 7:49 PM by Benjamin Bibik
Jim, thanks. That solution works fantastically. Wish I had found the answer hours ago.

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

Friday, June 08, 2007 2:29 AM by JOE
This problem is unsolovable.. Tell me proper steps to solve this problem. Reply soon

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

Friday, June 08, 2007 11:26 AM by Kathy Gray

I am getting this error when the session times-out.  Unfortunately, I am not allowed to set EnableEventValidation to False, so I am wondering if there is a way to catch this error before the popup window shows, and that way I can send the user back to the login page?

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

Monday, June 11, 2007 2:59 PM by Benjamin Boyle
Dear Eilon, I receive this error when my server sends a response back to the update panel. Why does my server send this message? How can I prevent it? If I can't prevent it, how can I suppress the error message? The update panels are updating on panels every second, so I don't care if they fail silently every now and then. Many thanks, ben

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

Friday, June 15, 2007 1:28 AM by Syed Saleem
I went through with all the solutions what is been provided in the above whole chat but nothing worked fine for me. Finally i got one solution which is working fine and also works fine for all the problems mentioned above. My problem was downloading a file from DB and wrting into the response stream to allow the client to save that file in his/her local system. for which i was getting Sys.WebForms.PageRequestManagerParserErrorException exception. This will happen when we use the AsyncPostBackTrigger trigger in the update panel (like ). whenever i used to click on download button i was getting that error. so along with the AsyncPostBackTrigger what i used for autorefresh i used the following code . after giving the above code whenevr i am clicking on download button it is downloading properly without any problem. the trigger elemnet of update panel finally looks like this: . For whichever event we want to modify the response stream for that event we have to mention in the PostBackTrigger and it will just works fine. Only thing in this is that the whole page gets postback only for that event for the rest of the things it will just works fine.

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

Tuesday, June 19, 2007 4:39 PM by Frodoqui

I have found another cause for this error, when i initialize a session variable during the curse of the postback caused by an update panel i receive this error.

I fixed it by initializing the session variable in the page_load event.

i hope this helps.

Frodoqui.

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

Thursday, June 21, 2007 7:04 PM by manbanner

Hi all,

In response to someones question about losing the ability to trace by trace enabled="false" - try linking to yoursite/trace.axd (http://localhost/trace.axd). It's a asp.net tracing tool that does not require rendering the trace on the same page. It's not new, it's been around a long time, but not often talked about.

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

Friday, June 22, 2007 9:53 AM by ksdeweb

This may or may not be helpful to someone, but I recently resolved this error by setting <pages smartNavigation="false" validateRequest="false"> in my webconfig.  Hope it helps someone ...

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

Tuesday, June 26, 2007 10:32 AM by Shaun Peet

Check your firewall settings too!

blogs.telerik.com/.../2528.aspx

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

Monday, July 09, 2007 5:34 AM by Marco

I bypassed this bug deleting the OutputCache directive from my aspx pages

# How I solved IIS AJAX problems

Monday, July 09, 2007 9:42 AM by ASP.NET AJAX Toolkit Forum Posts

I had come across several problems while creating an asp.net ajax application. I thought it might be

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

Wednesday, July 11, 2007 10:56 AM by Mark C.

Just thougt I would throw in something I found that may help.  My problem was the same as Greg B and Fred.  I could recreate it by stopping the "ASP .NET Development Server".  I would get the error EVERY time the page was loaded the first time.  Subsiquent page loads, even in another debug session, worked as long as the Development Server was not stopped.  After evaluating the ENTIRE page, not just within the Update Panel, I found where I mis-spelled a css class.(class="dumbspellingerror")  This was outside the Update Panel.  Once this was corrected, I no longer got the parser error.  FYI, I did try enableEventValidation="false" and that also made the error go away.  I removed that property once i corrected my spelling error.

Hope this helps someone.

# Sys.WebForms.PageRequestManagerParserErrorException &laquo; Hari&#8217;s Blog

Pingback from  Sys.WebForms.PageRequestManagerParserErrorException &laquo; Hari&#8217;s Blog

# Sys.WebForms.PageRequestManagerParserErrorException 错误的解决办法

Wednesday, July 18, 2007 10:54 AM by Dezwen

Sys.WebForms.PageRequestManagerParserErrorException 错误的解决办法

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

Wednesday, July 18, 2007 11:16 AM by Alex

Eilon,

I can confirm the bug together with the RoleManagement caching set to true. Switching it off solved my problem. The ErrorMessage linked to the following Code Snippet:

</div>|<html>

  <head>

'.

Regards,

Alex

# Run a Http Response Filter together with an Ajax Update Panel

Saturday, July 21, 2007 8:11 AM by Erik Lenaerts

This post continues from part one . In this previous post we created a Http Response Filter that translated

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

Thursday, July 26, 2007 4:49 AM by siderite

 I have a TabContainer with some of the tabs created dynamically, all inside an UpdatePanel. Sometimes, very rarely, usually after a compilation of a referenced library, I get the error with the message "Error parsing near '<html>

  <head>

'". A page refresh would normally make it work, but being on and off like that made it very hard to debug.

 I have saved the page output in a file and when the error occured, I checked the output. It was a valid Ajax output, containing NO <html> or <head> inside. I am going to try the Session fix above, see if it fixes anything, but beware that the PageRequestManagerParserErrorException does not seem to occur only when the ajax output is corrupted, but also in some other cases.

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

Thursday, July 26, 2007 4:57 AM by siderite

 The Session fix worked! Add a Session["Siderite"]="helped me" :) in Page_Load if not IsPostBack and this will remove a parse exception that appears out of nowhere when referenced components are being changed and the entire solution rebuilt (possibly when the Session is empty).

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

Wednesday, August 01, 2007 6:35 PM by Tony Colby

I've tried to user Response.Write() to send a bit of JavaScript to the client to open a new window using window.open() function.  THe page to be opened is the result of some server side processing to produce a PDF file on the server.  I'm looking for a solution to get the client to open the PDF in a new browser (the file name doesn't remain constant though and needs to be passed by the server).  I've tried using a label control but with very little success unless I cause the page to post back (which I can't force from the server - or can I?).  Any suggestions?  Cheers, Tony

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

Thursday, August 16, 2007 3:12 PM by Mike Garner

I finally verified a Sys.WebForms.PageRequestManagerParserErrorException error had to do with the user's firewall or proxy server and the "Remove Unknown Headers" setting.  One user at this company was not going through the proxy server and they could use our ASP.NET AJAX search application while others that went through the proxy server c