티스토리 뷰

728x90
반응형

        public ActionResult PopulityChartTop10()

        {

            System.Text.StringBuilder postParams = new System.Text.StringBuilder();

            postParams.Append("param1=dsadsadsadasd");

            postParams.Append("&param2=" + System.Web.HttpUtility.UrlEncode("urlEncodedValue"));


            // 코드페이지 번호는 http://msdn.microsoft.com/ko-kr/library/system.text.encoding.aspx 에서 확인하시면 됩니다.

            int euckrCodepage = 51949;

            System.Text.Encoding euckrEncoding = System.Text.Encoding.GetEncoding(euckrCodepage);

            byte[] result = euckrEncoding.GetBytes(postParams.ToString());

                        


            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://www.naver.com");

            webRequest.Method = "POST";

            webRequest.ContentType = "application/x-www-form-urlencoded; charset=utf-8";

            


            webRequest.ContentLength = result.Length;

            Stream postDataStream = webRequest.GetRequestStream();

            postDataStream.Write(result, 0, result.Length);

            postDataStream.Close();

            

                        

            HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

            Stream responseStream = webResponse.GetResponseStream();

            StreamReader sr = new StreamReader(responseStream, System.Text.Encoding.UTF8);

            

            return Json(sr.ReadToEnd(), JsonRequestBehavior.AllowGet);

        }

728x90
반응형