By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,173 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

HttpRequest.Filter and how best to use it

P: n/a
I have built a web app where I need to parse the entire http page before it
is returned to the client. Basically I am running a RegEx replace on it
which looks for any predefined macros and changes them to actual values.

I accomplished by setting the HttpRequest.Filter property to a stream class
which allows me to intercept the read and write (writes mainly). In the
Stream's Write property I simply scan through the buffer and replace the
appropriate macros.

This has all be working perfectly until recently where I noticed that
ASP.NET is chunking some of the larger pages (in other words, I don't always
get the entire page in one buffer inside the stream's Write method).
Occasionally, a macro will start at the end of the buffer but won't finish
until the next call to Write. So effectively, my RegEx doesn't replace it
as the macro isn't fully named yet.

I have found ways around this, essentially, build a buffer of my own in this
stream class and then parsing it all at once when completed. Is this good
to do? Wouldn't that break apps that turn of HttpResponse.BufferOutput
(i.e. they want it streamed directly to the browser)? Is there a
performance penalty in doing this?

I tried setting HttpResponse.BufferOutput to false and strangely, I didn't
get any calls to my Write method--I assumed I would get lots as ASP.NET
would be streaming data as soon as it is done processing it.

Any ideas?
Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.