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

  • 相关阅读:
    P3368 【模板】树状数组 2
    P3374 【模板】树状数组 1
    P1631 序列合并
    P1387 最大正方形
    P1197 [JSOI2008]星球大战
    P2866 [USACO06NOV]糟糕的一天Bad Hair Day
    P1196 [NOI2002]银河英雄传说
    SP1805 HISTOGRA
    P1334 瑞瑞的木板
    2019信息学夏令营游记
  • 原文地址:https://www.cnblogs.com/yinchuan/p/5345505.html
Copyright © 2011-2022 走看看