快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

HttpClientpost

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Xinleda.Common;
using Xinleda.Model;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpClient client = new HttpClient();


            FormUrlEncodedContent content = new FormUrlEncodedContent(
                new List>() {
                    new KeyValuePair("batdata[0].id", "213"),
                    new KeyValuePair ("token","qwe") });

            var result = client.PostAsync("http://localhost:55787/api/XldSalary/Update", content).Result.Content.ReadAsStringAsync().Result;


            Console.WriteLine(result);


            Console.ReadKey();
        }
    }
}

成都创新互联公司是一家专业提供十堰郧阳企业网站建设,专注与成都网站建设、成都做网站、H5高端网站建设、小程序制作等业务。10年已为十堰郧阳众多企业、政府机构等服务。创新互联专业网络公司优惠进行中。

 UploadPaydataModel model = new Xinleda.Model.UploadPaydataModel();
            model.entrname = "上海有限公司";
            model.batdata = new List() { new batdata() { bank = "名还是呢过" } };

            var content = SerializerHelper.JsonSerialize(model);

            WebRequest request = HttpWebRequest.Create("http://localhost:55787/api/XldSalary/Update");
            request.ContentType = "application/json";
            request.Method = "post";

            using (StreamWriter sw = new StreamWriter(request.GetRequestStream()))
            {
                sw.Write(content);
                sw.Close();
            }

            WebResponse r = request.GetResponse();
            string result = "";
            using (StreamReader sr = new StreamReader(r.GetResponseStream()))
            {
                result = sr.ReadToEnd();
                sr.Close();
            }
            Console.WriteLine(result);

            Console.ReadKey();

文章名称:HttpClientpost
路径分享:http://6mz.cn/article/psopsp.html

其他资讯