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;
}
}