HttpAccess.cs 674 B

1234567891011121314151617181920212223
  1. using System.Net;
  2. using System.Net.Http;
  3. namespace BanTur.Utility
  4. {
  5. public class HttpAccess
  6. {
  7. public static string Get(string url)
  8. {
  9. var clientHandler = new HttpClientHandler { AutomaticDecompression = (DecompressionMethods)(-1) };
  10. var webProxy = BanTurRuntime.Config.WebProxy;
  11. if (!string.IsNullOrWhiteSpace(webProxy))
  12. {
  13. clientHandler.Proxy = new WebProxy(webProxy);
  14. }
  15. using var client = new HttpClient(clientHandler);
  16. var content = client.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
  17. return content;
  18. }
  19. }
  20. }