For a specific set of Actions I am required to log the incoming Requests InputStream as well as the outgoing Response.OutputStream.
I envision using an ActionFilterAttribute for this and overriding the OnActionExecuted and OnResultExecuted methods.
So I'm starting with this idea...
public class ActionLoggerAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
base.OnActionExecuted(filterContext);
HttpRequestBase request = filterContext.HttpContext.Request;
// TODO: Log the Request.InputStream
}
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
base.OnResultExecuted(filterContext);
HttpResponseBase response = filterContext.HttpContext.Response;
// TODO: Log the Response.OutputStream
}
}
Ideally I'll just hook this up with the Enterprise Library logging since I'm already using it for Error logging.
- Am I accessing the Input and Output streams at the appropriate time?
- Can I use the Enterprise Library to easily log Streams?
- Is there an entirely different and better solution to my problem?
Thanks!