Ajax is a flexible and powerful technology, but sometimes “With great power comes great responsibility” ?. And also some kind of fragility and sensitivity to external factors.
In this case browsing the application worked somehow fine, but triggering a partial postback we were getting the following error on the browser:
The message received from the server count not be parser. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
If you get weird Ajax script errors, my experience tell me to always first check if Http compression is enabled on the web server (this is not the first time I tackle this topic), but this was not the case. An important thing to note is that the application was working perfectly fine when browser from the LAN, while it was failing when browsed from the Internet (no matter the browser we were using).
An important thing to note is that browsing from the Internet, our request was going through IAG:
Intelligent Application Gateway (IAG) is a remote access gateway that boosts productivity by giving mobile and remote workers, partners, and customers easy, flexible, and secure access to virtually any application from a broad range of devices and locations. Using a combination of SSL VPN (secure socket layer virtual private network), a Web application firewall, and endpoint security management, IAG provides employees, partners, vendors, and customers with secure and easy access from a broad range of devices and locations including kiosks, PCs, and mobile devices.
Basically IAG allows access to internal web applications over the internet. It does this by translating every HTML/script link it finds relating to the published Intranet server in the HTTP Response (both Header and Body).
To make a not so long story even shorter, there was a bug which has been fixed in .NET 3.5 SP1, which cause this error when “something” was modifying the headers collection of a request. But we were getting the error anyway (the customer was already running .NET 3.5 SP1) because IAG was modifying the body of a web request and this still supposed to cause the exception.
And just to clarify, this latter behavior is by design. The reason is proxy rewriting URLs on the fly (so we’re not just talking about IAG but every kind of proxy/firewall or even an HttpModule with this capability); the format that the UpdatePanel control uses to send the client updates is very sensitive to any modification made along the way to the client, and it is impossible to support every kind of possible modification that can be made by potentially countless applications and filters.
So there are three possible solutions in my opinion, which one to choose is up to you and your needs:
-
- Do not use the UpdatePanel: this means you cannot use Ajax and you must always do a full page postback
- Do not use the proxy, or make sure it is not tampering the request’s body (if possible, of course)
- Write your URLs so that they do not need to be rewritten by the proxy: this is the most complex, and maybe not really applicable solution (simply because of the names translation needed to access internal resources from the Internet)
Carlo
Quote of the day:
An expert is a person who has made all the mistakes that can be made in a very narrow field. – Niels Bohr