How can I get System.Net.Http.HttpClient to not follow 302 redirects?

One of the overloads of the HttpClient constructor takes a
WebRequestHandler argument. The HttpClient class uses this
WebRequestHandler for sending requests.

The WebRequestHandler class provides a property called AllowAutoRedirect
to configure the redirect behaviour. Setting this property to false
instructs the HttpClient to not follow redirect responses.

Here is a small code sample:

WebRequestHandler webRequestHandler = new WebRequestHandler();

webRequestHandler.AllowAutoRedirect = false;

HttpClient httpClient = new HttpClient(webRequestHandler);

// Send a request using GetAsync or PostAsync

Task<HttpResponseMessage> response = httpClient.GetAsync("http://www.google.com");

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)