views:

326

answers:

2

Hi,

I'm getting some js errors only for some users, and only every once in a while on a page that uses quite a bit of ASP.NET AJAX.

The page also does some intense SQL querying and some string manipulation to highlight text found in the search results.

Could this be a result of performance? Is it always safe to use ASP.NET AJAX in demanding situations or should I be looking to other AJAX techniques?

(By the way the errors I sometime see are):

Message: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 12031

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

+1  A: 

This particular exception is very common and can be caused by any one of the following:

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.

Complete Post : ASP.NET AJAX and Sys.Webforms.PageRequestManagerServerErrorException

You can grab the code which causes the error by using Visual Studio Debug feature. I don't know much but maybe it can help and also Firebug will help you to see server response and data you submit to the server.

Here is a video where you can see how to use Firebug to debug Ajax. See how I used Firebug to learn jQuery

But I don't think Asp.NET Ajax should be avoided in heavy loaded pages. That is actually what Ajax stands for right ? I mean it also relieves servers to send small pieces of pages instead of requesting the whole page again.

Braveyard
+1  A: 

ASP.NET AJAX has been known to not be the most performance intensive approach, but that's what you got i suppose in exchange for how simple it is to implement.

I do know you aren't allowed to do any Response.Writes within an update panel. That will cause your second error.

Jack Marchetti
Yeap : Response.Write() does the same thing like document.write and it clears the whole page and start new document.
Braveyard