Response.Filter problem in Application_PreSendRequestContent

S

Salim Afsar

Hi,

I'm trying to compress all requests.
When client send a request, I will compress the response and send it to
client.
For this purpose I get Response.Filter stream and try to read this
stream.(Because I need a string of response)
Here is my code:
protected void Application_PreSendRequestContent(object sender, EventArgs e)

{

Stream sTemp = Response.Filter;

sTemp = new TrimStream(sTemp);


StreamReader sr = new StreamReader(sTemp);

string strHTML = sr.ReadToEnd();

sr.Close();

}

I get an error on the 4th line(string strHTML = sr.ReadToEnd();
Here is my TempStream class.

public class TempStream : Stream

{

private Stream stream;

public TempStream(Stream stm)

{

stream = stm;

}

public override void Write(byte[] buffer, int offset, int count)

{


}

public override int Read(byte[] buffer, int offset, int count)

{

return stream.Read(buffer, offset, count);

}

public override bool CanRead

{

get { return true; }

}

public override bool CanSeek

{ get { return true; } }

public override bool CanWrite

{ get { return true; } }

public override long Length

{ get { throw new NotSupportedException(); } }

public override long Position

{

get { throw new NotSupportedException(); }

set { throw new NotSupportedException(); }

}

public override void Flush()

{

stream.Flush();

}

public override long Seek(long offset, SeekOrigin origin)

{

throw new NotSupportedException();

}

public override void SetLength(long value)

{

throw new NotSupportedException();

}

}

Any help will be appreciated kindly.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top