AW.Pay.Core.HTTPHelper.Get C# (CSharp) Method

Get() public static method

public static Get ( string url, int timeout, string contentType = "application/x-www-form-urlencoded" ) : string
url string
timeout int
contentType string
return string
        public static string Get(string url, int timeout, string contentType = "application/x-www-form-urlencoded")
        {
            string result = string.Empty;
            try
            {
                using (var client = new HttpClient())
                {
                    client.Timeout = new TimeSpan(0, 0, 0, 0, timeout);
                    var response = client.GetAsync(url).Result;
                    result = response.Content.ReadAsStringAsync().Result;
                };
            }
            catch (Exception e)
            {
                throw new Exception("GET请求错误" + e.ToString());
            }
            return result;
        }
    }

Usage Example

Example #1
0
        private string GetResponseTxt(string notify_id)
        {
            string veryfy_url = AlipayConfig.ALI_HTTPS_VERYFY_URL + "&partner=" + AlipayConfig.ALI_PARTER + "&notify_id=" + notify_id;
            string response   = HTTPHelper.Get(veryfy_url, 120000);

            return(response);
        }
HTTPHelper