zoukankan      html  css  js  c++  java
  • HttpWebRequest用法实例

    [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("上传成功!") ;         }

  • 相关阅读:
    Heroku
    Git基本命令(转)
    github之从零开发
    物理层、、。。。
    BeautifulSoup, 的使用
    路径设置
    http协议
    Python 的os模块与sys模块
    python 操作MySQL数据库
    多进程记要
  • 原文地址:https://www.cnblogs.com/yinchuan/p/5345505.html
Copyright © 2011-2022 走看看