Aug 31, 2007 12:55 PM
Your IIS security settings can cause you to get the dreaded PageRequestManagerParserErrorException.
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'.
We have a forms authentication site with a single windows authentication "internal login" page; this single page is configured through IIS with anonymous access disabled. The rest of the site has both the anonymous AND windows boxes checked.
If the Integrated Windows Authentication link is not checked on our server, we get the parse exception - but only in IE (everything is fine in Firefox.) Also, if I run Fiddler while accessing the site, it works fine! Presumably Fiddler is doing something that modifies the request, or changes some sort of security negotiation, and this makes the problem go away.
The HTML returned from the request is the whole of the target page, rather than the partial postback that was expected. The problem is not that the request is redirected to a different page. The target page is just failing to reallize that a partial postback was expected, and is rendering the whole page. This can happen when a firewall strips the X-MicrosoftAjax header, but that wasn't happening here; I confirmed that this header did make it to the target page.
So I still don't know exactly what was happening to cause the parse exception, but at least I've got a fix.
Aug 29, 2007 10:13 PM
I'm back to ASP.NET programming having fun with a highly complex user interface.
Our site uses UpdatePanels to bring in new content and we're warning on navigation away from the page - including the back button - by returning a message in onbeforeunload. But all of our ASP.NET LinkButton controls were triggering this warning, even when posting back to the same page. Here's my test page:
<%@ Page Language="vb" Strict="True" %>
var showMessage = true;
return "You are leaving the test page."
<body onbeforeunload="return beforeunload();">
<a href="#" onclick="showMessage=false;return false;">Anchor</a>
<asp:LinkButton runat="server">Default LinkButton</asp:LinkButton>
<asp:LinkButton runat="server" OnClientClick="showMessage=false;">
This shows the trick to using a LinkButton with an UpdatePanel, or in any situation where the page posts back to itself. The script for turning off the message must be in the onclick, and not in the href's
This is because in Internet Explorer, the sequence of events is
onclick, onbeforeunload, href, while in Firefox the sequence is
onclick, href, onbeforeunload.