0

I have an IErrorHandler set up for funneling all wcf errors through log4net. I'd like to get the json payload data from the request before logging it to the server, but I can't seen to find it in System.Web.Context.Current.Request. I expected it to be in the InputStream, but that's empty.

I'm currently using jquery to do an AJAX post with the json passed in as data.



$.ajax({
            url: 'http://test.com/myservice/service.svc',
            data: JSON.stringifyWcf({"id":1, "description":"thing"}),
            type: 'POST',
            processData: true,
            cache: false,
            contentType: 'application/json; charset=utf-8',
            timeout: 5000,
            dataType: 'json',
            success: function (result) {
                //do stuff
            }
});

Where I would like to get the payload {"id":1, "description":"thing"}

Trent
  • 2,122
  • 1
  • 24
  • 38
  • You provided too little information. You tagged it with asp.net-mvc, but you're talking about WCF. Are you trying to get the request in an ASP.NET MVC controller? – Daniel T. Feb 04 '11 at 23:52
  • If you could provide a sample of code where you're using jQuery to send the request and also the basics of how your controller is coded, that would help us towards an answer. – David Hoerster Feb 05 '11 at 01:57

2 Answers2

1

How about: OperationContext.Current.RequestContext.RequestMessage?

Johann Blais
  • 9,389
  • 6
  • 45
  • 65
  • this look like the right direction, but I'm still trying to figure out how to extract from it exactly. – Trent Feb 16 '11 at 02:13
1

I guess that the input stream is empty because it has already been consumed. You'll need to hook into the system before it reads the input stream to save it for later I believe. See Request.InputStream is empty when service call is made

Robert Cutajar
  • 3,181
  • 1
  • 30
  • 42