0
votes

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?

1
It seems you got a 200 status code. What were you expecting?gunr2171
Did you miss the "setup.html" part in your url variable?Klaus Gütter
EnsureSuccessStatusCode() could be hiding the actual error.Joel Coehoorn
It's a 200 status code yes but i want to know if it's my algo or my url that doesn't works. And where it is because the "Response Header:" is good so i really don't know.Dreinale
@KlausGütter i don't think so.Dreinale

1 Answers

0
votes

Check if external traffic (internet) can access your server's port 80 ? When you browse the IP address it should return the iis welcome page or the application that you installed (on port 80)