Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 23, 2011 02:10 PM by Nafe Jeries
Jun 11, 2008 06:36 PM|LINK
I am trying to save the request and response to a file using HttpModule.
Can someone please tell me if it is possible to capture the Reponse stream and save it to a file??. I can save the request using BeginRequest.
Jun 11, 2008 07:24 PM|LINK
Response.OutputStream can not be read directly (it can only be written to).
One possible solution not tested but can be tried:
1) Create a class derived from BufferedStream that overrides the Write method to do base.Write() AND write to a file (let's say the new class will be named FileWriterBufferedStream)
2) Set the HttpResponse.Filter (http://msdn.microsoft.com/en-us/library/system.web.httpresponse.filter.aspx) to:
Response.Filter = new FileWriterBufferedStream(Response.Filter);
Jun 11, 2008 08:32 PM|LINK
Thanks Aleris your responce really helped me move forward and could save the response at HttpModule level by overriding the write() method. But for somereason when it comes to the client it says :
"client found response content type of "", but expected "text/xml".request failed with empty response"
Any ideas on the above exception:
Jun 11, 2008 09:13 PM|LINK
Well my mistake i figured out the cause of the exception. when i wrote the response to a file using the override write(). I need to make sure that i write the responsestream back else it returns empty stream to the client.
Thanks for the response.
Aug 23, 2011 02:10 PM|LINK
Hellp Aleris, can you post the code, cause i'm facing this problem.