<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2800324515447939244</id><updated>2011-04-21T15:48:38.793-07:00</updated><category term='Random Firefox Ajax error.'/><title type='text'>My Tech Blog</title><subtitle type='html'>This is a place where I post my technical problems and solutions found especially in the Microsoft ASP.net world. My fave technologies are Ajax, Javascript, C# and Silverlight.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://bhaskarm.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2800324515447939244/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://bhaskarm.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Bhaskar M</name><uri>http://www.blogger.com/profile/15539607073179390509</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2800324515447939244.post-5162908764005092335</id><published>2007-10-26T12:02:00.000-07:00</published><updated>2008-05-23T18:39:36.725-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Random Firefox Ajax error.'/><title type='text'>Asp.net Ajax PageRequestManagerParserErrorException in Firefox</title><content type='html'>&lt;span style="font-family:verdana;font-size:85%;"&gt;&lt;br /&gt;When using Ajax update panels we get the PageRequestManagerParserErrorException intermittently. This is due to the proxy which removes the "X-MicrosoftAjax" = "Delta=true" header from the XMLHttpRequest while sending the request randomly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This was causing the Page to throw an alert with text:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;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 ''&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;After reading multiple posts, I could not find a solution to this problem except some places which mentioned that the proxy has to be removed. This is not an ideal solution as we could not ask all the users to remove the proxies.&lt;br /&gt;&lt;br /&gt;So I came up with a hack which works till there is a better solution available:&lt;br /&gt;&lt;br /&gt;This involves 2 steps in JS on the ClientSide and on the Server Side:&lt;br /&gt;&lt;br /&gt;In the Javascript:&lt;br /&gt;&lt;span style="color:blue;"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;window.isFireFox = (navigator.userAgent.indexOf("Firefox") != -1);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if(window.isFireFox)&lt;br /&gt;{&lt;br /&gt;        window.addEventListener('load',OnPageLoad,false);&lt;br /&gt;        function OnPageLoad()&lt;br /&gt;        {&lt;br /&gt;                 Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(OnBeginRequest);      &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        function OnBeginRequest(sender, args)&lt;br /&gt;        {&lt;br /&gt;                var delta = args.get_request().get_headers()['X-MicrosoftAjax'];   &lt;br /&gt;                if(delta == 'Delta=true')   &lt;br /&gt;                {&lt;br /&gt;                         var body = args.get_request().get_body() + 'X-MicrosoftAjax=' + encodeURIComponent('Delta=true');       &lt;br /&gt;   args.get_request().set_body(body);   &lt;br /&gt;                }&lt;br /&gt;         }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the Page Init Complete:&lt;br /&gt;&lt;span style="color:blue;"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;protected override void OnInitComplete(EventArgs e)&lt;br /&gt;{&lt;br /&gt;         #region Firefox Fix&lt;br /&gt;&lt;br /&gt;         ScriptManager sm = ScriptManager.GetCurrent(this);&lt;br /&gt;         if (IsPostBack &amp;amp;&amp;amp; Request.Browser.Browser == "Firefox"  &amp;amp;&amp;amp;  sm!=null &amp;amp;&amp;amp; sm.IsInAsyncPostBack == false &amp;amp;&amp;amp; Request.Form["X-MicrosoftAjax"] == "Delta=true")&lt;br /&gt;         {&lt;br /&gt;                  sm.GetType().GetField("_isInAsyncPostBack", System.Reflection.BindingFlags.NonPublic  System.Reflection.BindingFlags.Instance).SetValue(sm, true);&lt;br /&gt;         }&lt;br /&gt;         #endregion&lt;br /&gt;         base.OnInitComplete(e);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2800324515447939244-5162908764005092335?l=bhaskarm.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaskarm.blogspot.com/feeds/5162908764005092335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2800324515447939244&amp;postID=5162908764005092335' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2800324515447939244/posts/default/5162908764005092335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2800324515447939244/posts/default/5162908764005092335'/><link rel='alternate' type='text/html' href='http://bhaskarm.blogspot.com/2007/10/intermittent-pagerequestmanagerparserer.html' title='Asp.net Ajax PageRequestManagerParserErrorException in Firefox'/><author><name>Bhaskar M</name><uri>http://www.blogger.com/profile/15539607073179390509</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry></feed>
