티스토리 뷰
public static string postXMLHTTP(string sURL, string sParam, string requestType)
{
string contentType = string.Empty;
if (requestType.Equals("UTF-8"))
contentType = "text/xml;charset=UTF-8";
else
postXMLHTTP(sURL, sParam);
try
{
HttpWebRequest HttpRequest = (HttpWebRequest)WebRequest.Create(sURL);
HttpRequest.Method = "POST";
string postData = sParam;
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] PostValue = Encoding.UTF8.GetBytes(postData);
// Set the content type of the data being posted.
//HttpRequest.ContentType = "application/x-www-form-urlencoded";
HttpRequest.ContentType = "text/xml;charset=UTF-8";
HttpRequest.ContentLength = PostValue.Length;
Stream dataStream = HttpRequest.GetRequestStream();
dataStream.Write(PostValue, 0, PostValue.Length);
dataStream.Close();
HttpWebResponse HttpResponse = (HttpWebResponse)HttpRequest.GetResponse();
Stream respPostStream = HttpResponse.GetResponseStream();
StreamReader respReader = new StreamReader(respPostStream, Encoding.UTF8);
string strResponse = respReader.ReadToEnd();
HttpResponse.Close();
respReader.Close();
return strResponse;
}
catch (Exception ex)
{
return "ExceptionError : " + ex.Message;
}
}
'프로그래밍 > ASP.NET' 카테고리의 다른 글
System.Security.Cryptography.CryptographicException (0) | 2011.09.15 |
---|---|
상수 선언, const 와 readonly (0) | 2010.11.11 |
ASP.NET 에서 ServerSide XmlHttp 호출 (0) | 2010.11.11 |
ashx session (0) | 2010.11.10 |
Enterprise Library - Data Access Application Block (0) | 2010.04.29 |
DataBinder.Eval 대신 명시적인 캐스팅을 사용하자 (0) | 2010.04.27 |
HTTP Handler (0) | 2010.02.02 |
ASP.NET 파일형식 (0) | 2010.01.29 |