HttpClient 获取请求返回空响应

问题描述 投票:0回答:1

尝试执行 get 请求,但它一直给我“null”作为响应,测试了 URL,似乎没有问题。

using System.Net.Http;
using System.Threading.Tasks;
internal class Program
{

    static void Main(string[] args)
    {
        getit();
    }
    static async void getit()
    {
        HttpClient client = new HttpClient();
        var respo = await client.GetStringAsync("https://testnet.binancefuture.com/fapi/v1/klines?symbol=BTCUSDT&interval=1h&limit=10");
        Console.WriteLine(respo);
        
    }
}
c# get dotnet-httpclient
1个回答
0
投票

我想你必须等待方法

getit()

static async Task Main(string[] args)
// await getit();
© www.soinside.com 2019 - 2024. All rights reserved.