========================================
The source for the compression module is located here:
http://www.blowery.org/code/HttpCompressionModule.html
Note: Ben Lowery fiixed the code 4 months ago to work with Server.Transfer
and Response.Redirect.
I think my case is not part of his fix.
/// An HttpModule that hooks onto the Response.Filter property of the
/// current request and tries to compress the output, based on what
/// the browser supports.
///This module checks the Accept-Encoding HTTP header to determine if the
/// client actually supports any notion of compression. Currently, we
support
/// the deflate (zlib) and gzip compression schemes.
========================================
When I have it enabled in my web.config, the pages are sent to the browser
in compressed form.
But the module must be sending the headers "early" in the process. When I
run into an unhandled error, I log it and clear it in Global.asax and then
re-direct to my custom error form. This re-direct is what causes the dreaded
"http headers have already been sent" error. I am using a Try catch block
around my re-direct in Global.asax in an attempt to "eat the error".
========================================
I tried the settings ClearHeaders or ClearContent. But it did not stop the
error from occurring.
========================================
In Global.asax I have this: (remember, I was trying to load a page and got
an unhandled error)
========================================
'log error here. Then:
Server.ClearError()
'JF 8/9/2004 - See if this will prevent the error for "Server cannot append
header after HTTP headers have been sent." Nope.
Response.ClearContent()
Response.ClearHeaders()
Dim strErrorMessage As String = "We're sorry, but an unhandled error
occurred on the server. The Server Administrator has been notified and the
error logged."
Try
'this shared method sets some variables and then re-directs to my
standard error page.
MyUtilClass.DisplayErrorMessage("Application Error", strErrorMessage)
Catch except As Exception
'do nothing
End Try
========================================
Thanks for any advice.
--
Joe Fallon
"spalding" <sp*************@mail.codecomments.com> wrote in message
news:sp*************@mail.codecomments.com...
Hi Joe and Andreas
In what way are you using Response.Write and Response.Redirect at the
same time?
Joe, you mentioned that you were using a compression class to output
your data. Does it use the Response object in any way?
Would you be able to post a code snippet so we can see exactly how your
code is structured?
Chandra Sekhar has suggested a good solution; ClearHeaders or
ClearContent. Just make sure BufferOutput is true (it is by default). A
Javascript redirect is good but you don't know if it is disabled on the
client (and with many recent security issues it may be).
Alternatively, write your output to a string variable then use an
if...else statement for calling either Response.Write or
Response.Redirect.
Joe Fallon wrote: *I have this problem also.
And yes, I believe that is exactly how it is caused.
The question now is:
how do I detect this condition?
I have used Try Catch to eat the exception and this does not work
reliably
either.
I usually end up in my Global error handler and any attempt th
re-direct to
my custom error page causes this exception. It is quite frustrating.
I believe the cause is using Ben Lowery's httpCompression module.
This is an
excellent module for compressing data sent over the wire but when I
get an
error and try to re-direct to my custom page it is "too late" because
the
Headers have been sent by the compression module.
I would dearly love a solution to this issue as otherwise I may have
to
remove the compression feature.
--
Joe Fallon
"spalding" <sp*************@mail.codecomments.com> wrote in message
news:sp*************@mail.codecomments.com... >
> Andreas Klemt wrote:
>
> Hi
>
> Are you writing anything out to the Response stream prior to
calling > Redirect;
>
> eg.
>
> Response.Write("this is a test");
> //some more code...
> Response.Redirect(strNewASPPage);
>
> If so the first Response.Write will send a response to request
header > to the browser.
>
> If you then call Response.Redirect, you are sending a different
header > to the browser. This is an error. You can't send two different
headers > to the browser.
>
>
>
> --
> spalding
>
------------------------------------------------------------------------ > Posted via http://www.codecomments.com
>
------------------------------------------------------------------------ > *
--
spalding
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------