问题
I am facing a weird issue ,
We have a GET URL like below http://localhost:12345/xxxxx/abcsd . If am accessing the URL from the browser it's works fine. But accessing through the code It's giving an error
No connection could be made because the target machine actively refused it 127.0.0.1:12345
And making it more suprise , If I start fiddler the URL works from code.
I spent some good amount of time analyzing this issue not sure , what happening here . Any guess ?
回答1:
The most likely explanation is that the code in question is blocked by a firewall and thus the connection is refused because the application doesn't have permission to reach the target.
The next most likely explanation is that the target is listening only on IPv6 (not IPv4) and thus the connection fails when the DNS resolution returns the IPv4 address rather than the IPv6 address.
来源:https://stackoverflow.com/questions/33671989/localhost-not-getting-resolved-from-c-sharp-code