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();
        }
    }
}

公司主营业务:成都做网站、网站制作、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联建站是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联建站推出文登免费做网站回馈大家。
 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();

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前文章:HttpClientpost-创新互联
网站网址:http://scjbc.cn/article/digchs.html

其他资讯