Ome*_*r K 12 c# asp.net iis wcf
我一直在寻找几个小时,但我找不到解决方案.我将简要解释一下.
我正在学习WCF服务.我刚刚创建了一个服务并浏览它.这是配置文件:
<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="EmployeeServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="EmployeeServiceBehaviour" name="EmployeeConfiguration">
        <endpoint address="http://localhost:2005/EmployeeService.svc" binding="basicHttpBinding"
          bindingConfiguration="" contract="IEmployeeConfiguration" />
      </service>
    </services>
  </system.serviceModel>
  <system.web>
    <compilation debug="true"/>
  </system.web>
  <system.webServer>
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>
从Visual Studio浏览它似乎没有问题.它完美地运作.


其次,我试图在IIS上发布它.我在做什么是这样的:
我将服务发布到一个文件夹,并将此服务添加到IIS.

我选择端口3006作为端口.
在它的配置文件下面.请注意,我还将配置中的端口更改为3006
<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="EmployeeServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="EmployeeServiceBehaviour" name="EmployeeConfiguration">
        <endpoint address="http://localhost:3006/EmployeeService.svc" binding="basicHttpBinding"
          bindingConfiguration="" contract="IEmployeeConfiguration" />
      </service>
    </services>
  </system.serviceModel>
  <system.web>
    <compilation/>
  </system.web>
  <system.webServer>
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>
我正在等待顺利运行但是:


IIS为我提供了Chrome的空白页面

来自资源管理器的HTTP 400 Bad Request

最后,如果我从配置文件中删除地址部分一切正常.但其他困惑的是,在我的另一台计算机上面的情况(提供地址)后,我可以到达该服务.所以,我真的厌倦了为什么这个在一台计算机上工作而不在另一台计算机上工作.有人可以向我解释一下吗?
我知道它有点长,但我必须清楚地解释它.谢谢
根据我的搜索,我不应该提供一个地址.
msdn.microsoft.com/en-us/library/aa751792(v=vs.110).aspx
您必须始终为IIS托管的服务端点使用相对端点地址.如果端点地址未指向承载公开端点的服务的IIS应用程序,则提供完全限定的端点地址(例如,localhost/MyService.svc)可能导致服务部署中的错误.使用托管服务的相对端点地址可以避免这些潜在的冲突.