Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net.Http;
- class Program
- {
- static async Task Main()
- {
- // Create an instance of HttpClient
- HttpClient httpClient = new HttpClient();
- // Set custom User Agent
- string customUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36";
- httpClient.DefaultRequestHeaders.Add("User-Agent", customUserAgent);
- // Make a GET request to httpbin.io/user-agent
- HttpResponseMessage response = await httpClient.GetAsync("https://httpbin.io/user-agent");
- // Read and print the content
- string content = await response.Content.ReadAsStringAsync();
- Console.WriteLine(content);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement