I wrote the following program in C# using .NET 4.7.1:
var req = (HttpWebRequest) WebRequest.Create(myUrl); req.AllowAutoRedirect = false; var rsp = req.GetResponse(); Console.WriteLine(rsp.Headers["Location"]); The site I am requesting from is returning a 301 response, and the "Location" header contains the URL to redirect to.
If I do the exact same thing using .NET Core 2.1, I will instead get a WebException thrown from the call to GetResponse. How can I avoid this?