?
Solved

using chartdirector asp.net + WhitespaceModule

Posted on 2007-08-01
7
Medium Priority
?
597 Views
Last Modified: 2013-11-26
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.
0
Comment
Question by:efibn
  • 5
  • 2
7 Comments
 
LVL 18

Expert Comment

by:DropZone
ID: 19607534
What is it that you are trying to accomplis? Are you trying to remove all unnessesary whitespace?

      -dZ.
0
 
LVL 18

Expert Comment

by:DropZone
ID: 19607541
Also, can you post an excerpt of the output HTML generated, specifically a section that includes the tags that should load the charts.

    dZ.
0
 

Author Comment

by:efibn
ID: 19607914
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.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 18

Expert Comment

by:DropZone
ID: 19608755
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.
0
 
LVL 18

Expert Comment

by:DropZone
ID: 19608869
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.
0
 

Author Comment

by:efibn
ID: 19615699
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.
0
 
LVL 18

Accepted Solution

by:
DropZone earned 200 total points
ID: 19615750
Ah, I see.  You are generating the Chart dynamically from an aspx file and the WhiteSpaceModule was mangling its output!  Well, that makes a heck of a lot of sense.

However, your solution will solve the problem for that particular case, but may still cause you a headache if you are rendering any other non-plaintext content dynamically in the same way.  May I suggest that instead of comparing the URL for a preset name (like you are doing in your fix), you check the Response.ContentType and guarantee it is one of the appropriate types you want to filter, such as "text/html", "text/css", "text/javascript", "text/xhtml", etc.  Othewise, if you ever decide to return, say, a plaintext file to the user, the module will mangle it too.

       -dZ.
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question