WebClient请求接口,get和post方法


1,get方式

             string URI = "url";
            //实例化
            WebClient client = new WebClient();
           // client.UseDefaultCredentials = true;
            return Encoding.UTF8.GetString(client.DownloadData(URI));

2,post方式

             string URI = "url";
            string myParameters = "key=" + key + "&system_id=" + System_id + "";
            //实例化
            WebClient client = new WebClient();
          //  client.UseDefaultCredentials = true;
            client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
            client.Encoding = Encoding.UTF8;
            return client.UploadString(URI, myParameters);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM