tags:

views:

45

answers:

3

Hi,

Using the current HTTP Context, how can I see the content of the current POST request that has just been posted to the server?

+2  A: 

HttpContext.Current.Request.Form is a collection of name value pairs for posted content. I assume this is what you want rather than the raw post data...

Edit to add: My curiosity piqued I decided to go look for the raw post data. It seems there is a .InputStream property on the request object that "Gets the contents of the incoming HTTP entity body". I suspect this will be the raw data.

Chris
Usually this would work, but in this case I am trying to evaluate the request from a WCF web service. The post content is just one xml chunk, no name value pairs.
SilverSurfer
@SilverSurfer: Hopefully you saw my updated answer with the .InputSTream property. Does this allow you to do what you want? A bit of a faff having to work with a stream rather than just getting a string but hopefully it will do what you want...
Chris
A: 

the firebug extension of firefox lets you see exactly what is posted to the server. not sure if that's helpful to you or not.

Patricia
The request is not posted via a browser. It's originating from a third party client program.
SilverSurfer
that's probably something you should have mentioned in the question ;)
Patricia
Yes, I should have, sorry... BTW: I haven't downvoted your post. Even I would have wanted to, my account wouldn't let me.
SilverSurfer
looks like we have a serial down voter. lol.
Patricia
A: 

If you're speaking from a test/eval perspective. Use Fiddler. Assuming your WCF isnt doing anythign too fancy/non-standard, you can see the content of the request/response bodies.

Now from a code perspective, you'd need to access the Post content and parse through it as has been mentioned

Taylor
The request is not posted via a browser. It's originating from a third party client program.
SilverSurfer
.NET client services running on windows utilize the Win32 INET api to make their calls, which is what Fiddler analyses. Thats exactly why I recommended it OVER Firebug, which is a browser-only tool. Try the tool next time, before you get all overly zealous with the down-rank :)
Taylor
I haven't downvoted your post. I can't even do that with only one point on my account.
SilverSurfer
considering the question, this was a good answer. no need for it to be downvoted. +1 to counter the downvote :)
Patricia
interesting. Sorry for the assumption. Try Fiddler though, I use it for debugging WCF client<>server interactions
Taylor