Hi i need to know why my url don't take request but when i ping him it's work.
static async void check(string ip)
{
string url = "http://" + ip + "/";
try
{
HttpResponseMessage response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("\n{0} ==> OK\n", url);
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine("\n{0} ==> Exception Caught!", url);
Console.WriteLine("Message :{0} ", e.Message);
}
}
Output:
Exception thrown: 'System.Net.Http.HttpRequestException' in mscorlib.dll
http://192.168.0.236/ ==> Exception Caught!
Message :There was an error when the request was sent.
On the HTML website:
General:
Request URL: http://192.168.0.236/setup.html
Request Method: GET
Status Code: 200 OK
Remote Address: 192.168.0.236:80
Referrer Policy: strict-origin-when-cross-origin
Response Header:
HTTP/1.1 200 OK
Content-Type: text/html; charset=Windows-1252
Server: Volumic
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Connection: close
Request Header:
GET /setup.html HTTP/1.1
Host: 192.168.0.236
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36 Edg/87.0.664.52
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://192.168.0.236/
Accept-Encoding: gzip, deflate
Accept-Language: fr,fr-FR;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6
Cookie: sessionToken=48699711
Can someone help me understand where the problem of my url comes from?
url
variable? – Klaus GütterEnsureSuccessStatusCode()
could be hiding the actual error. – Joel Coehoorn