Is there any way to include the HTTP Body response content in Application Insights HTTP or dependency tracking modules? Its useful knowing what the HTTP response status code of a request is, but its really important us to know what the response message/data.
Ive looked at creating a custom Filter or Initializer but no properties seem to have any response content, how can I include it?
This actually requires a bit more than inspecting the properties of your Response object. You will have to use a Response Filter in order to capture the body before it's done.
The gist below has two files. One is the
CaptureStream.cs file that implements a Stream abastract class and just passes along the information. Along the way we append data in a StringBuilder.
In the other is just an example of a
Global.asax.cs that overrides the
Application_BeginRequest method and the
You can choose any method in the ASP.NET Application Lifecycle that you think is the right location. I chose these two because it was the first two I remember using in other projects.