Link to home
Start Free TrialLog in
Avatar of efibn
efibnFlag for United States of America

asked on

using chartdirector asp.net + WhitespaceModule

Hello,
I'm using asp.net 2005 framework 2.0 windows 2003 IIs 6.0, using: ChartDirector Version 4.1     .
I recently inserted the WhitespaceModule as suggestion for speeding up performance at the client side,
Thus charts won't load any more !
This module is really replacing any responses from the server to the client with this RegularExpression:      
private static Regex reg = new Regex(@"(?<=[^])\t{2,}|(?<=[>])\s{2,}(?=[<])|(?<=[>])\s{2,11}(?=[<])|(?=[\n])\s{2,}");
Doing this:  html = reg.Replace(html, string.Empty);
After a little invastigation, the problematic part is the last part (?=[\n])\s{2,} !
What is really the problem ?
How can I fix it ?
Why the charts won't load at the client side after all ?

Thanks,
Efi.
Avatar of DropZone
DropZone
Flag of United States of America image

What is it that you are trying to accomplis? Are you trying to remove all unnessesary whitespace?

      -dZ.
Also, can you post an excerpt of the output HTML generated, specifically a section that includes the tags that should load the charts.

    dZ.
Avatar of efibn

ASKER

Yes, I'm trying to remove all unnessesary whitespace.

Aboute the html that is generated: I allready doubled checked whether it damages the client code, and the answer was NO, the client code is changing but is working under the same project that has no WhiteSpaceModule configuration, which means that it dameges the server related Chart code that generated on run time and causes the client NOT to see the chart.

Efi.
I'm confused.  Obviously the output rendered to the client has been affected in some way that causes it to not work properly.  I am not familiar with the Chart component you are using, so I cannot guess what the problem is.

Where is this regexp being applied, to the output stream?

    -dZ.
I do not see anything wrong with that regexp pattern, except that it has a few superfluous matches:

(?<=[^])
I guess this is intended to match the beginning of the line, but [^] matches the negation of an empty set, which is useless.

(?<=[>])\s{2,11}(?=[<])
This matches from 2 to exactly 11 whitespace characters between html tags, but this is searched right after matching any quantity larger than 2 (with \s{2,}), so it is useless.  Besides, what is the point of looking for exactly 11 whitespace characters?

You can simplify it greatly by using the following:

(?<=\>)\s{2,}(?=\<)|(?=\n)\s{2,}

This will match any amount of whitespace greater than 2 between html tags, or after a new line.  But still, it is my opinion that if that is all that the module does, it may not work for all circumstances (which may be your problem).  For instance, if will eliminate any whitespace between angled-brackets, regardless of whether they are part of html tags or literals in strings.

Again, I cannot tell without seeing the original output and comparing it to the mangle one.

    -dZ.
Avatar of efibn

ASKER

Thank You all, I solved the problem !
First, the problem was that the Chart object was generating the PNG (image) files to the client using, Page name (eg. MyPage.aspx) And the ID of the chart, so it look like this:
"MyPage.aspx?ChartID=234628476" , That was the response from the server for a given image for  a chart.
Thus, when The module "Saw"   the string ".aspx" in that response it started filtering it according to the RegEx Mentioned above,
So the solution was easy, i add the following:
    if (app.Request.RawUrl.Contains(".aspx") && !app.Request.RawUrl.Contains("Chart"))
    {
      app.Response.Filter = new WhitespaceFilter(app.Response.Filter);
    }

Thank you all,
Efi.
ASKER CERTIFIED SOLUTION
Avatar of DropZone
DropZone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial