How to log request inputstream with HttpModule, then reset InputStream position

后端 未结 6 1421
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 01:51

I am trying to log the contents of an http request, using an IHttpModule like so:

public class LoggingModule : IHttpModule
{
    public void Init(HttpApplica         


        
6条回答
  •  温柔的废话
    2020-12-09 02:22

    this answer did not work. it returns an array that contains null values.

            var bytes = new byte[request.InputStream.Length];
            request.InputStream.Read(bytes, 0, bytes.Length);
            request.InputStream.Position = 0;
            string content = Encoding.ASCII.GetString(bytes);

    because the input stream consumed.

提交回复
热议问题