【发布时间】:2016-11-10 15:55:48
【问题描述】:
我在使用控制台应用程序托管 WCF 时正在学习 WCF(C#)。它没有显示任何错误,但是当我在浏览器浏览器中输入http://localhost:8080/ 时说它拒绝连接。请给我解决方案。enter image description here
我在配置文件中的代码如下
<services>
<service name="MyService.MyWService" behaviorConfiguration="mexBehaviour">
<endpoint address="HelloService" binding="basicHttpBinding" contract="MyService.IMyWService">
</endpoint>
<endpoint address="HelloService" binding="netTcpBinding" contract="MyService.IMyWService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080" />
<add baseAddress="net.tcp://localhost:8090"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
【问题讨论】:
-
在本地主机前添加
http:// -
试过了,没用
-
我发现了问题。这是因为我在控制台应用程序中托管 wcf 并且我没有通过使用 console.readline() 命令保持它的活动状态,这就是 localhost 不起作用的原因。它只存活了几毫秒
标签: c# .net visual-studio wcf configuration-files