logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -


For a specific set of tasks, I need to log in to the incoming request inputstream as well as outgoing response. is.

I am using an ActionFilterAttribute for this and overriding the OnActionExecuted and OnResultExecuted methods.

So I'm starting with this idea ...

  Public category ActionLoggerAttribute: ActionFilterArrbit {Public Override Zero On-Offed Execution (ActionActioned Contact Filter Filter) {base.OnActionAxecuted (FilterContext); HttpRequestBase request = filterContext.HttpContext.Request; // TODO: Log the request. InputStream} Public Override Zero OnResultExecuted (ResultExecutedContext FilterContext) {base.OnResultExecuted (filterContext); HTTPRPSPointBase Response = FilterContacts Hpptex response; // TODO: Log on Response.OutputStream}}   

Ideally I'll hook it up with enterprise library logging because I'm already using it for error logging.

  1. Am I reaching the input and output stream at the right time?
  2. Can I easily use the Enterprise Library to log in?
  3. Is anyone totally different and better solution to my problem?

    Thank you!

    You can use it to capture the response in order:

      Public Class Capture Response: MemoryStream {Private Redoni Stream _Stream; Public Capture Response (stream stream) {_stream = stream; } Write public override zero (byte [] buffer, int offset, int count) {// TODO: log feedback buffer // (note that it can be a part) _stream. Write (buffer, offset, count); }}   

    You may have a custom action attribute:

      public class ActionLoggerAttribute: ActionFilterAttribute {public override zero OnActionExecuting (ActionExecutingContext FilterContext ) {Var request = filterContext.HttpContext.Request; Var response = filterContext.HttpContext.Response; Feedback.filter = new capturer (feedback filter); // TODO: Log in request. InputStream Base .Onxaxing (FilterContact); }}    

Comments

Post a Comment

Popular posts from this blog

php - PDO bindParam() fatal error -

java - Why my included JSP file won't get processed correctly? -