views:

445

answers:

1

Hi,

I am using a HttpListener to implement a very simple http server, which is accepting a POST from a Java client. When the client calls I get a HttpListenerRequest, which contains all the form parameters. How can I extract the form parameters? I seem to have access only to the content stream....

+2  A: 

HttpListener is a low-level component, as is the HttpListenerRequest object you get for each request. Form data sent via POST is contained within the body, so you will have to process the stream and extract the form data yourself. The QueryString data is available to you because that is part of the request address, and does not require any stream processing to extract. That differentiates it from the form data, as processing the stream IS required.

jrista
Ah cool. Are there any helper classes I could use?
Grzenio
You might look into using the System.Web.HttpRuntime host. It is the base HTTP runtime used by ASP.NET, and as such, provides a lot of the ASP.NET services. It is not as full featured as ASP.NET, but should give you a lot more pre-packaged capabilities.
jrista