I\'m trying to write a Owin midleware component that would LOG every incoming request and response to the database.
Here\'s how far I managed to get.
I got stu
Response body is a write-only network stream by default for Katana hosts. You will need to replace it with a MemoryStream
, read the stream, log the content and then copy the memory stream content back into the original network stream. BTW, if your middleware reads the request body, downstream components cannot, unless the request body is buffered. So, you might need to consider buffering the request body as well. If you want to look at some code, http://lbadri.wordpress.com/2013/08/03/owin-authentication-middleware-for-hawk-in-thinktecture-identitymodel-45/ could be a starting point. Look at the class HawkAuthenticationHandler
.