how to get the URL HTTPClient redirects to

Viewed 3215

I'm using HTTPClient in my WPF application in order to send a GET message to the server. I know how to extract the content, aka HTML of the page i've been redirected to. Yet i'm unaware of how to get the url of the page i've been redirected to. I've already tried Headers.location, but that header is invalid

Sample code:

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();
        }
    }
}

The data i need should look like this (GET):

sample result

0 Answers
Related