将WCF配置为仅LOCALHOST侦听

编程入门 行业动态 更新时间:2024-10-26 07:24:35
本文介绍了将WCF配置为仅LOCALHOST侦听的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

类似于Visual Studio开发Web服务器(Cassini)的局限性,即它仅在localhost上运行,我有WCF Service实现,仅在localhost上需要.

Similar to the Visual Studio development web server (Cassini) limitation that it only servers on localhost, I have a WCF Service implementation that is only needed on localhost.

除了Windows防火墙提示允许程序在面向外部的NIC上侦听之外,我不介意其他计算机可以访问.由于这仅是内部所需,因此我宁愿限制WCF服务器端配置,以免触发防火墙检测器.

I wouldn't mind other machines having access, except that the Windows Firewall prompts to allow the program to listen on the externally-facing NIC. Since this is only needed internally, I would rather restrict the WCF Server-side configuration so that it doesn't trip the firewall detector.

binding.HostNameComparisonMode = HostNameComparisonMode.Exact是正确的解决方案吗?我不知道这怎么够.

Is binding.HostNameComparisonMode = HostNameComparisonMode.Exact the right solution? I don't see how this is enough.

====

像Cassini一样,此Service实现是其他需要网络通信的替代品.可以将客户端配置为连接到真实服务器或在localhost上运行的虚假实现.

Like Cassini, this Service implementation is a stand-in for something else which DOES require network communication. The client can be configured to connect to the real server or the fake implementation running on localhost.

推荐答案

这取决于您如何托管它.如果您使用的是IIS7或WAS,则WCF使用IIS的匹配模式.否则,如果使用HostNameComparisonMode.Exact,则是,主机名将始终是匹配的关键因素.如果主机名不匹配,则发送通常会失败.

It depends on how you are hosting it. If you are in IIS7 or WAS, then WCF uses IIS's mode of matching. Otherwise, if you use HostNameComparisonMode.Exact, then yes, the host name will always be a critical factor in matching. If the host name does not match, dispatch will generally fail.

应注意,精确并不是100%完全精确...它仍然允许主机名有所不同.如果您同时具有NetBios主机名和完整的DNS名称,则匹配仍然会发生,因为WCF将这两个视为相同.

It should be noted that exact is not 100% perfectly exact...it still allows some variation in the host name. If you have both a NetBios host name and a full DNS name, matching will still occur, as WCF treats those two as one and the same.

System.ServiceModel.BasicHttpBinding.HostNameComparisonmode

更多推荐

将WCF配置为仅LOCALHOST侦听

本文发布于:2023-07-15 01:59:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1108361.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:WCF   LOCALHOST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!