localhost拒绝连接

时间:2016-11-13 18:08:34

标签: wcf wcf-binding wcf-security

我在使用localhost:8733在浏览器中打开WCF服务时遇到问题。它说无法访问此站点

localhost拒绝连接。

在Google上搜索localhost 8733 主页搜索航班  ERR_CONNECTION_REFUSED

以下是在托管应用程序的控制台应用程序中使用的配置文件

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mex1">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="HelloIndigo.HelloIndigo" behaviorConfiguration="mex1">
        <endpoint address="HelloIndigo" binding="basicHttpBinding" contract="HelloIndigo.IHelloIndigo">


        </endpoint>
        <endpoint address="HelloIndigo" binding="netTcpBinding" contract="HelloIndigo.IHelloIndigo"></endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>

             <add baseAddress="http://localhost:8733/" />
            <add baseAddress="net.tcp://localhost:9000"/>
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
</configuration>

在主机控制台应用程序中,我正在编写以下代码

   ServiceHost host = new ServiceHost(typeof(HelloIndigo.HelloIndigo));

                host.Open();
                Console.WriteLine("Host is opened at " + DateTime.Now.ToString())

1 个答案:

答案 0 :(得分:1)

第二天早上在办公室,当我打开项目时出现了同样的问题 - &#34;无法访问此网站&#34;。根据我之前对此问题的经验,我更改了端口号并开始工作。但这一次,它没有任何帮助。然后我尝试了另一种方式(见下面的截图)。

问题:

a problem

解决方案:

solution, step 1

enter image description here

这是对我有用的另一种方式。我希望这能帮助那些面临同样问题的人。