Trying to remove unneeded characters does not work with AjaxManager

4 posts, 0 answers
  1. Jason Maronge
    Jason Maronge avatar
    322 posts
    Member since:
    Jan 2005

    Posted 25 Apr 2007 Link to this post

    I have the Render method on my base page overridden to remove whitespaces and return lines, etc. 

            protected override void Render(HtmlTextWriter writer)  
            {  
                StringWriter stringWriter = new StringWriter();  
                HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);  
                base.Render(htmlWriter);  
                string html = stringWriter.ToString();  
                html = html.Replace("\t"""); // tabs  
                html = html.Replace("  "" "); // double spaces  
                html = html.Replace(" />""/>"); // space before end of tags  
                html = html.Replace(">\r"">"); // space before end of tags  
                html = html.Replace(">\n"">"); // space before end of tags  
                writer.Write(html);  
            } 

    Everything works fine with the regular ajax manager but the new one seems to have a problem with me doing this. (Sys.WebForms.PageRequestManagerParseErrorException: The message recieved from the server could not be parsed. etc...)  I assume it is due to how MS formats the return string to the browser.  Am I out of luck on getting this to work? 

    Thanks... Jason
  2. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 25 Apr 2007 Link to this post

    Jason-

    Without doing a lot of research, one way to determine which replacement is causing problems would be to comment out all of your replacements and slowly add them back until the Ajax problems occur. That will at least make it clear which of your replacements is really causing the problem (if not all of them).

    Thanks~
    Todd
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jason Maronge
    Jason Maronge avatar
    322 posts
    Member since:
    Jan 2005

    Posted 25 Apr 2007 Link to this post

    Todd,

        I had tried that and it turns out that the only Replace I can keep in is the Replace(">\n"">");.  I do not think it is that big of a deal since it was not saving that much space to start with.  I am using compression on the site so it might be overkill to remove the characters anyway.  I was just wondering if anyone knew what the issue was. 

    Thanks... Jason
  5. Mike
    Mike avatar
    524 posts
    Member since:
    Feb 2007

    Posted 25 Apr 2007 Link to this post

    It's probably something internal to MS AJAX, e.g. the way it Diff's the page on partial rendering to figure out what needs to be sent to client, etc...

    But indeed, string replacing on large Html chunks may prove slower than just sending it through the pipe (and let Http compression take care of the rest).

    Still, it's a curious fact that the rad Ajax engine (the original one) does not have this problem...
Back to Top