I am currently working with the HttpListener class. I have created a little API with it and i now want to log the payload of each request (if there is one).
Unfortunately, I encountered a problem while doing this. Once I read the Request.InputStream for writing it into my log, I am unable to reset the Position property, as well as getting the Length. I assume the input stream is not buffered and therefore this operations are not available (although I don't quite understand why Length is unavailable).
The input stream might be needed at a later time, so I tried copying it into a MemoryStream via .CopyTo, but this wont work either. Of course there would be the option of reading it once and handing it over to the next methods who might need it, but I would prefer keeping the original InputStream property.
Is there any way of achieving this?