简体   繁体   中英

Force a C# program which uses HttpClient to use IPv6 only when also IPv4 is available

I have a C# program, which also depends on other libraries, which uses HttpClient through the libraries to get data from a server.

On the machine where I run the program, I have both IPv6 and IPv4 available.

I want to make sure that the program uses IPv6 only for its HttpClient connections, excluding IPv4.

Is there a way to achieve this, possibly without having to modify the source code of the libraries which use HttpClient, ie with some kind of "per process" setting in the Main method which disables IPv4 for the whole process?

Check this: Disable/Enable IPv6

You can basically modify the registry. It is a bit of a hack fix, but I can't think of another solution at the moment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM