[HttpPost]       

  public ActionResult Setmobile()       

  {         

    string text = "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>";  根据需要的数据拼xml数据        

            string postData = text;//System.Web.HttpUtility.UrlEncode(text, System.Text.Encoding.UTF8);

            byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(postData);

            HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create("url"); //发送地址 http://localhost:7118/Server/Default.aspx

            objWebRequest.Method = "POST";//提交方式

            objWebRequest.ContentType = "application/x-www-form-urlencoded";

            objWebRequest.ContentLength = byteArray.Length;

            Stream newStream = objWebRequest.GetRequestStream(); // Send the data.

            newStream.Write(byteArray, 0, byteArray.Length); //写入参数

            newStream.Close();             return Content("上传成功!") ;         }

posted on 2016-04-01 16:56  三人之行,必有我师  阅读(419)  评论(0编辑  收藏  举报