localhost not getting resolved from c# code

我只是一个虾纸丫 提交于 2019-12-24 12:48:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!