title: Unable to read input stream
body: <p>I am using <code>ActionFilterAttribute</code> to get the request before hitting the controller as below :</p>
  
  <pre><code> public override void OnActionExecuting(HttpActionContext actionContext)
   {
       using (var stream = new MemoryStream())
       {
          HttpContextBase context = (HttpContextBase)actionContext.Request.Properties["MS_HttpContext"];
          context.Request.InputStream.Seek(0, SeekOrigin.Begin);
          context.Request.InputStream.CopyTo(stream);
          requestBody = Encoding.UTF8.GetString(stream.ToArray());
       }
   }
  </code></pre>
  
  <p>The above method is working for small request but for a large json it is giving me this error : </p>
  
  <blockquote>
    <p>Either BinaryRead, Form, Files, or InputStream was accessed before the internal storage was filled by the caller of HttpRequest.GetBufferedInputStream. </p>
  </blockquote>
  
  <p>And the input stream gives this error </p>
  
  <blockquote>
    <p>context.Request.InputStream threw an exception of type System.InvalidOperationException System.IO.Stream {System.InvalidOperationException}</p>
  </blockquote>
  
  <p>As I found in my research that it is an issue with the timeout but I am unable to change the timeout in the code. I tried changing the values in the web.config file <code>maxRequestLength="102400000"</code> and <code>maxAllowedContentLength="209715100"</code> but still I am facing the same error.<br>
  If I read the <code>GetBufferedInputStream</code> but still same issue it is reading just a part of the buffer, not the entire stream.</p>
  
  <p>I also tried the below : </p>
  
  <pre><code> Stream InStream;
   int Len;
   InStream = HttpContext.Current.Request.InputStream;
   Len = System.Convert.ToInt32(InStream.Length);
   byte[] ByteArray = new byte[Len + 1];
   InStream.Seek(0, SeekOrigin.Begin);
   InStream.Read(ByteArray, 0, Len);
   var jsonParam = System.Text.Encoding.UTF8.GetString(ByteArray); 
  </code></pre>
  
  <p>Note that if I set the content type <code>application/xml</code> or <code>application/x-www-form-urlencoded</code> it works, but if I set it to <code>application/json</code> it gives me this error!!</p>
  
  <p>Please advise!</p>