here is my code:
using HttpClient client = new HttpClient();
try
{
HttpResponseMessage response = await client.GetAsync("http://131.189.89.86:11920/SetupWizard.aspx/yNMgLvRtUj");
}
catch (HttpRequestException e)
{
Console.WriteLine($"Request error: {e.Message}");
}
and it gives me this error: System.Net.Http.HttpRequestException: 'Received an invalid status line: 'HTTP/2 200 '.'
I also tried to downgrade Http Version like this:
var request = new HttpRequestMessage(HttpMethod.Get, "http://131.189.89.86:11920/SetupWizard.aspx/yNMgLvRtUj")
{
Version = new Version(1, 1)
};
HttpResponseMessage response = await client.SendAsync(request);
but no success.
here is a TCP hack which works even server is broken:
var host = "131.189.89.86";
var port = 11920;
using var client = new TcpClient();
await client.ConnectAsync(host, port);
using var stream = client.GetStream();
// Manually craft an HTTP/1.0 style request
var request = "GET /SetupWizard.aspx/yNMgLvRtUj HTTP/1.0\r\nHost: 131.189.89.86\r\nConnection: close\r\n\r\n";
byte[] requestBytes = Encoding.ASCII.GetBytes(request);
await stream.WriteAsync(requestBytes, 0, requestBytes.Length);
byte[] buffer = new byte[8192];
int bytesRead;
var response = new StringBuilder();
do
{
bytesRead = await stream.ReadAsync(buffer, 0, buffer.Length);
response.Append(Encoding.ASCII.GetString(buffer, 0, bytesRead));
} while (bytesRead > 0);
Console.WriteLine("---- RAW SERVER RESPONSE ----");
Console.WriteLine(response.ToString());
but how to do it via httpclient? any hack or trick?
maybe the problem is from server, butthere's no but or maybe, and this isn't a small error. WebForms never supported HTTP/2 and you can't just hack support by changing the response payload . HTTPS is a defacto requirement - all major browsers require at least TLS v1.2 AND the ALPN extension. And no, we can't open that URL. HTTP/2 is enabled by default in ASP.NET Core applications, even Minimal APIs. Use ASP.NET Core if you really want to use HTTP/2others will skip such small errorsare you sure, and what "small error" would that be? There are 2 errors in that status line. Using the wrong protocol is a critical error. Ignoring an invalid reason phrase is indeed a small error but so rare that the HttpClient team gave it a very low priority. cURL dumps the raw response, it doesn't try to parse it, and as the cURL docs say HTTP/2 won't be used withhttp://URLs unless you usecurl --http2 http://example.com/