WebClient Does not automatically redirect

Try adding

request.AllowAutoRedirect = true;

right under the

var request = base.GetWebRequest(address);

It solved some similar problems for me, even though AllowAutoRedirect is supposed to be true by default.


That shouldn't be surprising, given that HttpWebRequest is not a browser. If you need to perform these redirects, then check the HttpWebResponse.StatusCode, and make another request if it's a redirect code in the 300's. Note from the link under 10.3 Redirection 3xx:

This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request. The action required MAY be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD. A client SHOULD detect infinite redirection loops, since such loops generate network traffic for each redirection.

Tags:

C#

Webclient