문제

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?

도움이 되었습니까?

해결책

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top