本地主机拒绝WCF连接



我正在学习WCF(c#),而我正在使用控制台应用程序托管WCF。它没有显示任何错误,但当我在浏览器中输入http://localhost:8080/浏览器说它拒绝连接。请提供解决方案。输入图片描述

我的代码在配置文件中给出如下

    <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>

你得到的错误是由于浏览器无法找到网站localhost。您应该使用以下格式访问本地主机地址:

http[s]://localhost:<port number>

您还可以通过访问127.0.0.1查看本地主机地址,这是您的本地主机的环回地址。

127.0.0.1:8080

最新更新