This method will send data to a website page using the “POST” method.
Use with
ASCIIEncoding encoding = new ASCIIEncoding();
PostData(encoding.GetBytes(“Value=testvaluetosend”), “http://www.dbhagen.com/demo.aspx”);
private static string PostData(byte[] data, string address)
{
try
{
Uri uri = new Uri(address);
WebRequest request = WebRequest.Create(uri);
request.Method = “POST”;
request.ContentType = “application/x-www-form-urlencoded”;
request.ContentLength = data.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(data, 0, data.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.Write(responseFromServer);
// Clean up the streams.
reader.Close();
dataStream.Close();
response.Close();
return (responseFromServer);
}
catch (Exception e)
{
Console.Write(e.ToString());
return (“Fail”);
}
}
Normally, http://fashion.global-supplier.com Would be the Best Wearing for Feast
You See, http://www.homeleader.com.cn/juicer.html Dominate the Fashion Trend of Khabarovsk
Top 5 Spring/Summer 2010 http://www.gocooler.com/ Fashion Mode
http://www.dfpressurevessel.com , The Best Carnival Finds for Auntheat exchanger