本地主机无法从C#代码中解析 [英] localhost not getting resolved from c# code

查看:64
本文介绍了本地主机无法从C#代码中解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临一个奇怪的问题,

I am facing a weird issue ,

我们有一个类似 http://localhost:12345/xxxxx/abcsd 的GET URL.如果要从浏览器访问URL,则可以正常工作.但是通过代码访问 出现错误

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

更令人惊奇的是,如果我启动小提琴手,则URL可从代码开始工作.

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 ?

推荐答案

最可能的解释是,所讨论的代码已被防火墙阻止,因此连接被拒绝,因为应用程序没有没有权限达到目标.

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.

下一个最可能的解释是目标仅侦听IPv6(不是IPv4),因此当DNS解析返回IPv4地址而不是IPv6地址时,连接将失败.

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.

这篇关于本地主机无法从C#代码中解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆