public static string GetHttp(string baseUrl, System.Collections.Generic.Dictionary <string, string> dictParam, bool isurlencode = true) { string result = string.Empty; string lastUrl = WebRequestHelper.GetLastUrl(baseUrl, dictParam, isurlencode); WebRequest webRequest = WebRequest.Create(new Uri(lastUrl)); webRequest.Timeout = 20000; WebResponse response = webRequest.GetResponse(); System.IO.Stream responseStream = response.GetResponseStream(); System.IO.StreamReader streamReader = new System.IO.StreamReader(responseStream, System.Text.Encoding.UTF8); result = streamReader.ReadToEnd(); streamReader.Close(); responseStream.Close(); return(result); }
public static string Request_WebClient(string uri, string paramStr, System.Text.Encoding encoding, string username, string password) { if (encoding == null) { encoding = System.Text.Encoding.UTF8; } string arg_0F_0 = string.Empty; WebClient webClient = new WebClient(); webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); byte[] bytes = encoding.GetBytes(paramStr); if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { webClient.Credentials = WebRequestHelper.GetCredentialCache(uri, username, password); webClient.Headers.Add("Authorization", WebRequestHelper.GetAuthorization(username, password)); } byte[] bytes2 = webClient.UploadData(uri, "POST", bytes); return(encoding.GetString(bytes2)); }