public static async Task <string> GetHttpAsync(string url, int count = 3) { while (true) { var client = new CookieClient(); var content = string.Empty; try { // If user is NOT authenticated (cookie got deleted in GetWebResponse()), return empty result if (String.IsNullOrEmpty(Settings.Default.sessionid)) { return(string.Empty); } content = await client.DownloadStringTaskAsync(url); } catch (Exception ex) { Logger.Exception(ex, "CookieClient -> GetHttpAsync, for url = " + url); } if (!string.IsNullOrWhiteSpace(content) || count == 0) { return(content); } count = count - 1; } }
public static async Task<string> GetHttpAsync(string url, int count = 3) { while (true) { var client = new CookieClient(); var content = string.Empty; try { content = await client.DownloadStringTaskAsync(url); } catch (Exception ex) { Logger.Exception(ex, "CookieClient -> GetHttpAsync, for url = " + url); } if (!string.IsNullOrWhiteSpace(content) || count == 0) return content; count = count - 1; } }
public static async Task <string> GetHttpAsync(string url, int count = 3, bool IgnoreCookieState = false) { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; while (true) { var client = new CookieClient(); var content = string.Empty; try { // If user is NOT authenticated (cookie got deleted in GetWebResponse()), return empty result if (IgnoreCookieState == false && String.IsNullOrEmpty(Settings.Default.sessionid)) { return(string.Empty); } System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return(true); // **** Always accept }; System.Net.ServicePointManager.Expect100Continue = false; url = url.Replace("http://", "https://"); content = await client.DownloadStringTaskAsync(url); } catch (Exception ex) { Logger.Exception(ex, "CookieClient -> GetHttpAsync, for url = " + url); } if (!string.IsNullOrWhiteSpace(content) || count == 0) { return(content); } count = count - 1; } }
public static async Task <string> GetHttpAsync(string url, int count = 3) { while (true) { var client = new CookieClient(); var content = string.Empty; try { content = await client.DownloadStringTaskAsync(url); } catch (Exception ex) { Logger.Exception(ex, "CookieClient -> GetHttpAsync, for url = " + url); } if (!string.IsNullOrWhiteSpace(content) || count == 0) { return(content); } count = count - 1; } }
public static async Task<string> GetHttpAsync(string url, int count = 3) { while (true) { var client = new CookieClient(); var content = string.Empty; try { // If user is NOT authenticated (cookie got deleted in GetWebResponse()), return empty result if (String.IsNullOrEmpty(Settings.Default.sessionid)) { return string.Empty; } content = await client.DownloadStringTaskAsync(url); } catch (Exception ex) { Logger.Exception(ex, "CookieClient -> GetHttpAsync, for url = " + url); } if (!string.IsNullOrWhiteSpace(content) || count == 0) return content; count = count - 1; } }