old mode 100755
new mode 100644
| | |
| | | /// </summary> |
| | | /// <param name="getUrl">接口地址</param> |
| | | /// <returns></returns> |
| | | public async static Task<string> GetWebRequest(string getUrl) |
| | | public static async Task<string> GetWebRequest(string getUrl) |
| | | { |
| | | |
| | | string responseContent = ""; |
| | |
| | | /// <param name="paramData">提交json数据</param> |
| | | /// <param name="dataEncode">编码方式(Encoding.UTF8)</param> |
| | | /// <returns></returns> |
| | | public async static Task<string> PostWebRequest(string postUrl, string paramData, Encoding dataEncode) |
| | | public static string PostWebRequest(string postUrl, string paramData, Encoding dataEncode) |
| | | { |
| | | string responseContent = string.Empty; |
| | | try |
| | |
| | | /// <param name="paramData">提交json数据</param> |
| | | /// <param name="dataEncode">编码方式(Encoding.UTF8)</param> |
| | | /// <returns></returns> |
| | | public async static Task<string> PutWebRequest(string postUrl, string paramData, Encoding dataEncode) |
| | | public static string PutWebRequest(string postUrl, string paramData, Encoding dataEncode) |
| | | { |
| | | string responseContent = string.Empty; |
| | | try |
| | |
| | | } |
| | | return responseContent; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// delete数据接口 |
| | | /// </summary> |
| | | /// <param name="postUrl">接口地址</param> |
| | | /// <param name="paramData">提交json数据</param> |
| | | /// <param name="dataEncode">编码方式(Encoding.UTF8)</param> |
| | | /// <returns></returns> |
| | | public static string DeleteWebRequest(string postUrl, string paramData, Encoding dataEncode) |
| | | { |
| | | string responseContent = string.Empty; |
| | | try |
| | | { |
| | | byte[] byteArray = dataEncode.GetBytes(paramData); //转化 |
| | | HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl)); |
| | | webReq.Method = "DELETE"; |
| | | webReq.ContentType = "application/json"; |
| | | webReq.ContentLength = byteArray.Length; |
| | | using (Stream reqStream = webReq.GetRequestStream()) |
| | | { |
| | | reqStream.Write(byteArray, 0, byteArray.Length);//写入参数 |
| | | //reqStream.Close(); |
| | | } |
| | | using (HttpWebResponse response = (HttpWebResponse)webReq.GetResponse()) |
| | | { |
| | | //在这里对接收到的页面内容进行处理 |
| | | using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default)) |
| | | { |
| | | responseContent = sr.ReadToEnd().ToString(); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ex.Message; |
| | | } |
| | | return responseContent; |
| | | } |
| | | } |
| | | } |