WCF监听基地址anyip
我希望我的服务主机有任何IP的基地址 所以我尝试了这个
new ServiceHost(typeof(LoggingController),new Uri("0.0.0.0"));
,它给了我无效的 URI 格式,
有人知道我应该如何写这个吗?
好吧,我尝试从本地 LAN 外部访问它,但它不起作用,我使用 tcpiplistener 制作了一个小型测试软件,我开始监听同一端口,并将 tcpip 协议的基地址设置为 anyip 和小型测试软件工作了,所以我发现我需要做的就是为 Web 服务设置相同的设置 -
TcpListener tcpListener = new TcpListener(IPAddress.Any,10021);
这也意味着我的系统管理员完成了他的工作,确保端口/服务器可以从外部访问,现在我的 Web 服务不应该工作吗!?它可以工作,但我无法从外部访问它,如果我在同一台电脑上运行客户端,我可以从同一台电脑访问它
i want my servicehost to have the base address of any IP
so i tried this
new ServiceHost(typeof(LoggingController),new Uri("0.0.0.0"));
and it gives me invalid URI format
any one knows how should i write this ?
well i tried to access it from outside of my local lan and it didnt work , i made a small test software using tcpiplistener and i started listening to the same port and i set the base address of the tcpip protocol to anyip and the small test software worked so i figured out all i need to do is setting the same for the Webservice –
TcpListener tcpListener = new TcpListener(IPAddress.Any,10021);
this works which also mean my system admin did his job of making sure the port/server is accessable from outside, now shouldnt my webservice work !? it work but i cant access it from outside , i can access it from the same pc if i run client on the same pc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下代码在类似情况下适用于我:
The following code works for me in a similar situation:
让我想起我们的软件遇到的一个问题。 Web 服务的默认配置使用 Windows 网络凭据来应用基于消息的安全性,由于域/网络凭据,该安全性无法在其他网络上工作。我们的解决方案是禁用服务绑定的安全性(这可能有点棘手,具体取决于您使用的绑定)。对于像 WebHttpBinding 这样的默认绑定,它只是在构造函数中传递一个参数。
希望这有帮助!
Reminds me of a problem we had with our software. The default configuration of the webservice used windows network credentials to apply message based security which - due to the domain/network credentials - won't work from another network. Our solution was to disable security on the service binding (which may be a bit tricky depending on the binding you use). For the default bindings like
WebHttpBinding
it's just passing a parameter in the constructor.Hope this helps!