WCF使用Winform做宿主,http访问,Localhost可以,IP地址不可以

Alice_AL 2017-09-18 05:33:50
做了一个WCF程序,使用Winform做宿主,实现http的访问,测试时使用Localhost一切正常。

1. 防火墙已经关闭

以下是配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<system.web>
<compilation debug="true" />
</system.web>
<!-- 部署服务库项目时,必须将配置文件的内容添加到
主机的 app.config 文件中。System.Configuration 不支持库的配置文件。-->
<system.serviceModel>

<bindings>
<webHttpBinding>
<binding name="HttpJsonBinding" crossDomainScriptAccessEnabled="true"/>
</webHttpBinding>
</bindings>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
<services>
<service name="JsonServerDLL.JsonServer">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="HttpJsonBinding"
contract="JsonServerDLL.IJsonServer">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8742/JsonServer/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,
请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="True"/>
<!-- 要接收故障异常详细信息以进行调试,
请将以下值设置为 true。在部署前设置为 false
以避免泄漏异常信息-->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

</configuration>
...全文
1740 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Alice_AL 2017-09-19
  • 打赏
  • 举报
回复
引用 1 楼 Coder_delphi 的回复:
同样遇到了,帮顶
在win7 上不行,但是在xp上面可以。我win7的防火墙也关了啊
Alice_AL 2017-09-19
  • 打赏
  • 举报
回复
试了其他的电脑,包括win7 的,其他电脑都可以,貌似就我的电脑不行。
Coder_delphi 2017-09-18
  • 打赏
  • 举报
回复
同样遇到了,帮顶

12,163

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧