Here’s how you can enforce the usage of IPv4 in Dual Stack environments with HttpWebRequests in C#/.NET:
string host = @"www.peschuster.de"; IPHostEntry ipHostEntry = Dns.GetHostEntry(host); IPAddress address = ipHostEntry.AddressList.FirstOrDefault(a => a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) ?? ipHostEntry.AddressList.FirstOrDefault(); var request = HttpWebRequest.Create("http://" + address.ToString() + "/2016/04/force-httpwebrequest-to-ipv4") as HttpWebRequest; request.Host = host; request.GetResponse();
This is a very basic example. You should add some checks, whether the address could actually be resovled, etc. for use in production.