Groups | Blog | Home
all groups > asp.net > january 2005 >

asp.net : HttpResponse.Filter clearing and what is happening behind the scenes


Chris Simmons
1/31/2005 11:30:29 PM
Hello:

I am trying to better understand the HttpResponse.Filter property and,
although I think I "get it," I am wondering what is going on behind
the scenes.

I was initially stumped with the thing because all the samples I came
across kept using the property as an argument to the custom filter
Stream's constructor. What I then figured out was that this is the
way that multiple filters can be chained onto the Response stream. For
example:

// C# Code follows

// Add a filter to the stream
SomeCustomStreamFilter aFilter =
new SomeCustomStreamFilter( Response.Filter );
Response.Filter = aFilter;

// ...

// Attach another filter to the stream
AnotherCustomFilter anotherFilter =
new AnotherCustomFilter( Response.Filter );
Response.Filter = anotherFilter;

// C# Code ends

The only questions I had remaining are:
1. To what is HttpResponse.Filter initially set?
2. How do you clear the filter (remove any filters)? Set it to null?

Assuming you set the filter to null, is there something underneath the
covers that tells Response to then just start sending Response.Write
directly to the output stream?

Or perhaps I am just totally not understanding the whole concept. Can
someone enlighten me?

Thanks ...
--
bruce barker
2/1/2005 9:50:44 AM
logically its the HttpResponse's original OutputStream.

-- bruce (sqlwork.com)


[quoted text, click to view]
| Hello:
|
| I am trying to better understand the HttpResponse.Filter property and,
| although I think I "get it," I am wondering what is going on behind
| the scenes.
|
| I was initially stumped with the thing because all the samples I came
| across kept using the property as an argument to the custom filter
| Stream's constructor. What I then figured out was that this is the
| way that multiple filters can be chained onto the Response stream. For
| example:
|
| // C# Code follows
|
| // Add a filter to the stream
| SomeCustomStreamFilter aFilter =
| new SomeCustomStreamFilter( Response.Filter );
| Response.Filter = aFilter;
|
| // ...
|
| // Attach another filter to the stream
| AnotherCustomFilter anotherFilter =
| new AnotherCustomFilter( Response.Filter );
| Response.Filter = anotherFilter;
|
| // C# Code ends
|
| The only questions I had remaining are:
| 1. To what is HttpResponse.Filter initially set?
| 2. How do you clear the filter (remove any filters)? Set it to null?
|
| Assuming you set the filter to null, is there something underneath the
| covers that tells Response to then just start sending Response.Write
| directly to the output stream?
|
| Or perhaps I am just totally not understanding the whole concept. Can
| someone enlighten me?
|
| Thanks ...
| --
| Chris Simmons

AddThis Social Bookmark Button