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

  • 相关阅读:
    流程控制
    小结
    运算符
    进制之间的转换
    自动类型转换和强制类型转换
    变量
    关键字,标识符,
    NGINX 做TCP转发(端口转发)并记录日志
    redash安装
    解决 es CircuitBreakingException 问题(Data too large Error)
  • 原文地址:https://www.cnblogs.com/yinchuan/p/5345505.html
Copyright © 2011-2022 走看看