Pregunta

I want to simulate a HttpGet request on my asp.net website. The request should have no Accept-Header. How can I do that using webrequest or webclient in .NET?

¿Fue útil?

Solución

Use the System.Net.Http.HttpClient class. Create a console application and add the Microsoft.Net.Http nuget package.

var httpClient = new HttpClient();
HttpResponseMessage response = httpClient.GetAsync("http://www.example.com").Result;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top