标签:
/// <summary> /// post请求 /// </summary> /// <param name="url">地址</param> /// <param name="data">数据</param> /// <returns>返回响应的数据</returns> public string POST(string url, string data) { string respMsg = string.Empty; byte[] postData = Encoding.UTF8.GetBytes(data); WebClient webClient = new WebClient(); webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); try { byte[] responseData = webClient.UploadData(url, "POST", postData); respMsg = Encoding.UTF8.GetString(responseData); } catch (WebException web_Error) { respMsg += "ERROR:" + web_Error.StackTrace + web_Error.Message; } catch (Exception e) { respMsg += "ERROR:" + e.StackTrace + e.Message; } return respMsg; }
标签:
原文地址:http://www.cnblogs.com/LJC-Home/p/5644339.html