I have an IErro开发者_如何学CrHandler 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"}
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
How about: OperationContext.Current.RequestContext.RequestMessage
?
精彩评论