protected void HttpPost()
{
String callUrl = "http://localhost/post/";
String postData = "a=1&b=2";
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(callUrl);
// 인코딩 UTF-8
byte[] sendData = UTF8Encoding.UTF8.GetBytes(postData);
httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = sendData.Length;
Stream requestStream = httpWebRequest.GetRequestStream();
requestStream.Write(sendData, 0, sendData.Length);
requestStream.Close();
HttpWebResponse httpWebResponse = (HttpWebResponse) httpWebRequest.GetResponse();
StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding("UTF-8"));
string return = streamReader.ReadToEnd();
streamReader.Close();
httpWebResponse.Close();
console.Write("return: " + return);
}