Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 132065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:12:14+00:00 2026-05-11T06:12:14+00:00

I have an ISAPI filter for IIS 6 which does some custom processing using

  • 0

I have an ISAPI filter for IIS 6 which does some custom processing using the bytes-sent field of the response. I’d like to update that for IIS 7, but I’m running into a problem. None of the IIS 7 events seem to have access to the content-length, bytes sent, or any data which would let me calculate the content-length or bytes sent. (I know the content-length header and bytes sent are not the same, but either will work for this purpose.)

From what I can tell, the content-length header is added by HTTP.SYS after the managed modules have finished executing. Right now I have an event handler which runs on EndRequest. If I could get at the output stream I could calculate what I need myself but the managed pipeline doesn’t seem to have access to that either.

Is there some way of getting the content-length or bytes sent in the managed pipeline? Failing that, is there some way I can calculate content-length or bytes sent from objects available in the managed pipeline?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:12:15+00:00Added an answer on May 11, 2026 at 6:12 am

    To get at the bytes sent you can use the HttpResponse.Filter property. As the MSDN docs say this property gets or sets a wrapping filter object that is used to modify the HTTP entity body before transmission.

    You can create a new System.IO.Stream that wraps the existing HttpResponse.Filter stream and counts the bytes passed in to the Write method before passing them on. For example:

    public class ContentLengthModule : IHttpModule {     public void Init(HttpApplication context)     {         context.BeginRequest += OnBeginRequest;         context.EndRequest += OnEndRequest;     }      void OnBeginRequest(object sender, EventArgs e)     {         var application = (HttpApplication) sender;         application.Response.Filter = new ContentLengthFilter(application.Response.Filter);     }      void OnEndRequest(object sender, EventArgs e)     {         var application = (HttpApplication) sender;         var contentLengthFilter = (ContentLengthFilter) application.Response.Filter;         var contentLength = contentLengthFilter.BytesWritten;     }      public void Dispose()     {     } }  public class ContentLengthFilter : Stream {     private readonly Stream _responseFilter;      public int BytesWritten { get; set; }      public ContentLengthFilter(Stream responseFilter)     {         _responseFilter = responseFilter;     }      public override void Flush()     {         _responseFilter.Flush();     }      public override long Seek(long offset, SeekOrigin origin)     {         return _responseFilter.Seek(offset, origin);     }      public override void SetLength(long value)     {         _responseFilter.SetLength(value);     }      public override int Read(byte[] buffer, int offset, int count)     {         return _responseFilter.Read(buffer, offset, count);     }      public override void Write(byte[] buffer, int offset, int count)     {         BytesWritten += count;         _responseFilter.Write(buffer, offset, count);     }      public override bool CanRead     {         get { return _responseFilter.CanRead; }     }      public override bool CanSeek     {         get { return _responseFilter.CanSeek; }     }      public override bool CanWrite     {         get { return _responseFilter.CanWrite; }     }      public override long Length     {         get { return _responseFilter.Length; }     }      public override long Position     {         get { return _responseFilter.Position; }         set { _responseFilter.Position = value; }     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 179k
  • Answers 179k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer XPath will help you to find nodes, but not really… May 12, 2026 at 3:52 pm
  • Editorial Team
    Editorial Team added an answer for ($i = $x ; $i <= $y; $i++) {… May 12, 2026 at 3:52 pm
  • Editorial Team
    Editorial Team added an answer To save a lot of time, is there any reason… May 12, 2026 at 3:52 pm

Related Questions

I've been tasked with making an already existing e-commerce site SE friendly - which
I usually develop websites on the WAMP/XAMPP and host it on Linux servers. All
We are migrating from asp classic to .net. Unfortunately they named all of the
This code snippet is part of an isapi redirect filter written in managed c++

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.