Reputation: 777
Is is possible to set an HttpClient to follow redirection only if this is a redirection on the same domain ?
I guess we could do that by checking somehow the redirected url and manually check if it is in the same domain (not sure if we can actually do that). Or maybe there is an option I did not find to do that automatically ?
Upvotes: 1
Views: 410
Reputation: 100527
No, there is no option to follow just some redirects. You need to disable automatic "follow redirect" and handle 301/302 responses yourself by checking "location" header on the response.
See
new HttpClient(new HttpClientHandler { AllowAutoRedirect = false})
response.Headers.GetValues("Location")
Upvotes: 3