Patrick Desjardins
Patrick Desjardins

Reputation: 140803

HttpListenerRequest where are the POST parameter?

I have search in MSDN and I can't figure where are the POST parameters from HttpListenerRequest?

Any idea?

*QueryString seem to have only Get parameter not post

Upvotes: 5

Views: 3998

Answers (1)

Patrick Desjardins
Patrick Desjardins

Reputation: 140803

After few hours of search (I was searching before posting here) I realized that I need to send back a request to get the form parameter. So once I have the HttpListenerRequest fill up the POST parameters aren't inside. You need to send an other request to get them:

//POST param
if (webRequest.Method == "POST")
{
    StreamReader getPostParam = new StreamReader(request.InputStream, true);
    postData = getPostParam.ReadToEnd();
    byte[] postBuffer = System.Text.Encoding.Default.GetBytes(postData);
    postDataStream.Write(postBuffer, 0, postBuffer.Length);
    postDataStream.Close();
}
//END POST param

Upvotes: 6

Related Questions