【问题标题】:Method not allowed 405 when using IIS使用 IIS 时方法不允许 405
【发布时间】:2012-09-21 10:45:34
【问题描述】:

我有以下 WCF:

    [OperationContract]
    IList<OperationRoomDto> GetOperationRooms();

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

远程服务器返回错误:(405) Method Not Allowed。

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

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

  <endpoint address="http://server/WcfService"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMessageService"
            contract="MyProject.Web.Wcf.IMessageService" name="BasicHttpBinding_IMessageService">
  </endpoint>

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

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

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

【问题讨论】:

标签: asp.net .net wcf iis-7 wcf-binding


【解决方案1】:

我发现问题了,是因为wcf的Url不正确,漏掉了服务文件名

<endpoint address="http://server/WcfService"

应该变成:

<endpoint address="http://server/WcfService/Service.svc"

【讨论】:

  • NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!我确实花了 小时 试图解决这个问题,结果证明这是问题所在。谢谢你:)
  • :) 很高兴您的问题解决了,我也花了很多时间才解决。
猜你喜欢
  • 2021-11-24
  • 1970-01-01
  • 1970-01-01
  • 2018-05-06
  • 1970-01-01
  • 1970-01-01
  • 2011-09-01
  • 2012-06-29
  • 2013-03-13
相关资源
最近更新 更多