使用IIS时不允许405的方法

Nou*_*uny 6 .net asp.net wcf iis-7 wcf-binding

我有以下WCF:

    [OperationContract]
    IList<OperationRoomDto> GetOperationRooms();
Run Code Online (Sandbox Code Playgroud)

我有一个使用此WCF的网站,当我使用Visual Studio(Asp.Net开发服务器)时,它工作正常,但是当我将WCF部署到IIS时,我得到以下异常:

远程服务器返回错误:(405)方法不允许.

我做了一个简单的网站来测试这个WCF(在IIS上)并且它工作正常.

这是web.config文件的一部分:

  <endpoint address="http://server/WcfService"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMessageService"
            contract="MyProject.Web.Wcf.IMessageService" name="BasicHttpBinding_IMessageService">
  </endpoint>
Run Code Online (Sandbox Code Playgroud)

以及这部分Web服务配置文件:

  <system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true" />
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
Run Code Online (Sandbox Code Playgroud)

我试图调试w3wp.exe服务以获取任何隐藏的异常,我在Web服务方法上设置了一个断点,但调试器甚至没有到达那里,并且在到达Web服务类之前发生了异常.

Nou*_*uny 12

我想出了问题,这是因为wcf的url不正确,它错过了服务文件名

<endpoint address="http://server/WcfService"
Run Code Online (Sandbox Code Playgroud)

它应该成为:

<endpoint address="http://server/WcfService/Service.svc"
Run Code Online (Sandbox Code Playgroud)