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 限流配置
    Nginx 跨域配置
    LVS实现负载均衡原理及安装配置详解
    Tomcat基本概念
    Hapoxy 基本配置概念
    rsync断点续传
    Nginx概念
    angular img标签使用err-src
    $ionicLoading自定义加载动画
    h5+jquery自制相机,获取图片并上传
  • 原文地址:https://www.cnblogs.com/yinchuan/p/5345505.html
Copyright © 2011-2022 走看看