Click here to Skip to main content
15,889,462 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Tool for testing ASPX pages Pin
DavidNohejl26-Dec-06 12:15
DavidNohejl26-Dec-06 12:15 
QuestionHow does Flickr do it? Pin
asimeqi26-Dec-06 9:59
asimeqi26-Dec-06 9:59 
AnswerRe: How does Flickr do it? Pin
jszpila26-Dec-06 10:18
jszpila26-Dec-06 10:18 
GeneralRe: How does Flickr do it? Pin
prolibertine26-Dec-06 13:39
prolibertine26-Dec-06 13:39 
AnswerRe: How does Flickr do it? Pin
MaxRelaxman27-Dec-06 8:35
MaxRelaxman27-Dec-06 8:35 
QuestionDocument Parsers Pin
alexfromto26-Dec-06 9:28
alexfromto26-Dec-06 9:28 
AnswerRe: Document Parsers Pin
Paddy Boyd26-Dec-06 23:34
Paddy Boyd26-Dec-06 23:34 
QuestionHow to determine the size of Response.OutputStream? Pin
jszpila26-Dec-06 9:11
jszpila26-Dec-06 9:11 
Hello all,
I'm in the process of writing an HTTP Module that will determine the size of the response and display it. I'm pretty new the http module thing so there's probably a good way to do this that I haven't found yet, but I've tried everything I can think of. Here's what I have so far:
public class ResponseSizeHttpModule : IHttpModule
   {
       public int RespSize;

       public void Init(HttpApplication application)
       {
           application.PreSendRequestHeaders += new EventHandler(this.ResponseCheck);
           application.EndRequest += new EventHandler(this.ResponseMessage);
       }

       private void ResponseCheck(Object source, EventArgs e)
       {
           HttpApplication application = (HttpApplication)source;
           HttpContext context = application.Context;
           StreamReader reader = new StreamReader(context.Response.OutputStream);

           reader.ReadToEnd();
           reader.Close();

           byte[] buffer = System.Text.Encoding.UTF8.GetBytes(reader.ToString());

           RespSize = buffer.Length;
       }

       private void ResponseMessage(Object source, EventArgs e)
       {
           HttpApplication application = (HttpApplication)source;
           HttpContext context = application.Context;
           context.Response.Write("Page size: " + RespSize + " bytes.");
       }

       public void Dispose(){}
   }
So far, the message comes up but the page size is always 0, so that's not right. It's come to my attention that the bold part that OutputStream is write-only, if I understand this correctly. How would I go about intercepting what's being written to the OutputStream so I can determine its size? Like I said, my knowledge of this particular facet of .Net isn't all that great, so if anyone can recommend a good method or alternative, I'd be glad to hear it.

Thanks in advance,
Jan

-------------------
abort, retry, fail?

QuestionProduct versioning Guidelines Pin
ssmith72126-Dec-06 7:48
ssmith72126-Dec-06 7:48 
QuestionRe: Product versioning Guidelines Pin
Venkatesh Mookkan27-Dec-06 18:34
Venkatesh Mookkan27-Dec-06 18:34 
QuestionRequest from Mobile Web Page Pin
Bala Munugoti26-Dec-06 3:32
Bala Munugoti26-Dec-06 3:32 
QuestionMasterpage problem Pin
smruti_ranjan26-Dec-06 2:38
smruti_ranjan26-Dec-06 2:38 
AnswerRe: Masterpage problem Pin
asithangae26-Dec-06 23:15
asithangae26-Dec-06 23:15 
GeneralRe: Masterpage problem Pin
smruti_ranjan27-Dec-06 0:39
smruti_ranjan27-Dec-06 0:39 
Questiongetting the focus on the popup Pin
abdelhameed8126-Dec-06 2:22
abdelhameed8126-Dec-06 2:22 
Questionwant some idea Pin
mohd imran abdul aziz26-Dec-06 1:45
mohd imran abdul aziz26-Dec-06 1:45 
AnswerRe: want some idea Pin
Vikram kshatriya28-Dec-06 19:06
Vikram kshatriya28-Dec-06 19:06 
QuestionQuery string Pin
MoeInsairat26-Dec-06 1:42
MoeInsairat26-Dec-06 1:42 
AnswerRe: Query string Pin
_AK_26-Dec-06 2:01
_AK_26-Dec-06 2:01 
GeneralRe: Query string Pin
MoeInsairat26-Dec-06 2:10
MoeInsairat26-Dec-06 2:10 
GeneralRe: Query string Pin
_AK_26-Dec-06 2:32
_AK_26-Dec-06 2:32 
QuestionCan I add elements in to a Drop down list server control Pin
indian14326-Dec-06 1:20
indian14326-Dec-06 1:20 
AnswerRe: Can I add elements in to a Drop down list server control Pin
Christian Graus26-Dec-06 15:40
protectorChristian Graus26-Dec-06 15:40 
GeneralRe: Can I add elements in to a Drop down list server control Pin
indian14326-Dec-06 17:44
indian14326-Dec-06 17:44 
QuestionGridview: How to display menu like grid Pin
BalasahebK26-Dec-06 0:27
BalasahebK26-Dec-06 0:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.