如何获取HTTPClient重定向到的URL

时间:2016-03-25 13:47:12

标签: c# wpf redirect httpclient

我在WPF应用程序中使用HTTPClient,以便向服务器发送GET消息。我知道如何提取内容,即我已被重定向到的页面的HTML。然而,我并不知道如何获取我被重定向到的页面的网址。 我已经尝试过Headers.location,但该标头无效

示例代码:

private async Task getToken()
{
    using (HttpClient client = new HttpClient())
    using (HttpResponseMessage response = await client.GetAsync(getURL))
    {
        var a = response.Headers.Location;
        using (HttpContent content = response.Content)
        {
            // ...Read the string.
            result = await content.ReadAsStringAsync();
        }
    }
}

我需要的数据应如下所示(GET):

sample result

0 个答案:

没有答案
相关问题