title: How to log request inputstream with HttpModule, then reset InputStream position
body: <p>I am trying to log the contents of an http request, using an IHttpModule like so:</p>
  
  <pre><code>public class LoggingModule : IHttpModule
  {
      public void Init(HttpApplication context)
      {
          context.BeginRequest += ContextBeginRequest;
      }
  
      private void ContextBeginRequest(object sender, EventArgs e)
      {
          var request = ((HttpApplication)sender).Request;
          string content;
  
          using (var reader = new StreamReader(request.InputStream))
          {
              content = reader.ReadToEnd();
          }
  
          LogRequest(content)
      }
  }
  </code></pre>
  
  <p>The problem is that after reading the input stream to the end, the InputStream seems to have either disappeared or more likely, the cursor is at the end of the stream.</p>
  
  <p>I have tried <code>request.InputStream.Position = 0;</code> and <code>request.InputStream.Seek(0, SeekOrigin.Begin);</code> but neither work.</p>