Httpwebrequest POST
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://192.168.1.50/julie/test.aspx");// Set AllowWriteStreamBuffering to 'false'.
myHttpWebRequest.AllowWriteStreamBuffering = false;
string postData = "userid=232";
// Set 'Method' property of 'HttpWebRequest' class to POST.
myHttpWebRequest.Method = "POST";
ASCIIEncoding encodedData = new ASCIIEncoding();
byte[] byteArray = encodedData.GetBytes(postData);
// Set 'ContentType' property of the 'HttpWebRequest' class to "application/x-www-form-urlencoded".
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
// If the AllowWriteStreamBuffering property of HttpWebRequest is set to false,the contentlength has to be set to length of data to be posted else Exception(411) is raised.
myHttpWebRequest.ContentLength = byteArray.Length;
Stream newStream = myHttpWebRequest.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);
newStream.Close();
Console.WriteLine("\nData has been posted to the Uri\n\nPlease wait for the response..........");
// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Nogen der kan fortælle mig hvorfor det der ikke poster som det skal? Har fundet den ca samme stump kode flere steder men ingen af dem poster parametre med over?
