C# WebRequest WebClient Post请求Demo



WebRequest WebClient Post请求发送数据的方式如下:

public void WebClientPost()
 {
            System.Net.WebClient WebClientObj = new System.Net.WebClient();
            System.Collections.Specialized.NameValueCollection PostVars = new System.Collections.Specialized.NameValueCollection();
            
            //添加

            PostVars.Add("Pram1", "测试1");
            PostVars.Add("Pram2", "测试2");


            byte[] byRemoteInfo = WebClientObj.UploadValues("http://192.168.1.244/WebPortal/PlaceOrder.ashx", "POST", PostVars);

           string sRemoteInfo = System.Text.Encoding.Default.GetString(byRemoteInfo);
}


你可能感兴趣的:(C# WebRequest WebClient Post请求Demo)