15
When you accept a request from HttpListener, you get an HttpListenerContext. From there, you can get an HttpListenerRequest - and that has an InputStream property which you can read the data from.
To read text data (such as JSON) you can use the ContentEncoding property and build a StreamReader. For example:
var context = listener.GetContext();
var request = context.Request;
string text;
using (var reader = new StreamReader(request.InputStream,
request.ContentEncoding))
{
text = reader.ReadToEnd();
}
// Use text here