我在配置文件中定义了带有"假"域名的端点.我们的想法是,这样可以简化部署,因为我们只需在环境的hosts文件中设置"假"域名的IP地址,而不是修改配置文件.例如,在我的本地开发盒中,我将在hosts文件中有一个条目
127.0.0.1 fake.domain
Run Code Online (Sandbox Code Playgroud)
以及我可能拥有的用户接受环境
192.45.34.31 fake.domain
Run Code Online (Sandbox Code Playgroud)
但在我的配置文件中,我只有端点
<endpoint address="http://fake.domain/someServiceBase/SomeService.svc" ... />
Run Code Online (Sandbox Code Playgroud)
但是,WCF似乎完全忽略了hosts文件.我可以将地址复制到浏览器中,它会立即生效,但是WCF客户端(位于本地开发盒上)会出现"找不到主机"错误.
为什么WCF会忽略hosts文件?
编辑: 附加注释,如果我替换端点地址以直接在配置文件中使用实际IP地址,例如,
<endpoint address="http://127.0.0.1/someServiceBase/SomeService.svc" ... />
Run Code Online (Sandbox Code Playgroud)