c# HttpResponseMessage GetAsync return empty content on page with meta tag refresh

114 views Asked by At

I want to download a zip file from url. But the url (https://petra.assurance-maladie.fr/fs/index.PnS?reqid=230620085933huRgfH9fPQwyDDqpJTw2B7d997a) doesn't download the zip directly, there is a refresh meta tag in html content whitch give the real link to download it (control key is added) :

<meta http-equiv="refresh" content="0; url=/fs/index.PnS?valreq=230620085933huRgfH9fPQwyDDqpJTw2B7d997a&valid[1]=1&auchk=ee814695e4a13c0fed06a5d050c10d9f">

When i use this function :

using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync(https://petra.assurance-maladie.fr/fs/index.PnS?reqid=230620085933huRgfH9fPQwyDDqpJTw2B7d997a).ConfigureAwait(false);
                using (StreamReader stream = new StreamReader(await response.Content.ReadAsStreamAsync()))
                {
                    return stream.ReadToEnd();
                }
            }

it return empty string and i don't know how to retrieved url in meta tag refresh to be able to download the zip file.

Any idea ?

Thanks

0

There are 0 answers