protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
var request = filterContext.HttpContext.Request;
var inputStream = request.InputStream;
inputStream.Position = 0;
using (var reader = new StreamReader(inputStream))
{
string headers = request.Headers.ToString();
string body = reader.ReadToEnd();
string rawRequest = string.Format(
"{0}{1}{1}{2}", headers, Environment.NewLine, body
);
// TODO: Log the rawRequest to your database
}
}
Oh and if you start doing that, I hope you have already planned the budget you will need for purchasing additional storage on your servers. Coz if you start logging the entire raw request on each request you're gonna need storage.