1. private async Task GetValueAsync()
    2. {
    3. try
    4. {
    5. using (WebClient client = new WebClient())
    6. {
    7. //地址
    8. string path = $"{webUrl}/api/Value";
    9. client.Headers.Add(HttpRequestHeader.Authorization, $"Bearer {token}");
    10. string value = await client.DownloadStringTaskAsync(path);
    11. txbMsg.Text = $"获取到数据={value}";
    12. }
    13. }
    14. catch (Exception ex)
    15. {
    16. txbMsg.Text = $"获取数据出错={ex.Message}";
    17. }
    18. }