【问题标题】:Hosting WCF service on IIS (The resource cannot be found)在 IIS 上托管 WCF 服务(找不到资源)
【发布时间】:2012-06-24 14:06:08
【问题描述】:

我正在制作 WFC 服务。当我从 Visual Studio 调试它时一切正常,但是当我在真正的 IIS 上部署它时遇到了问题。

部署后我仍然可以获得 WSDL,但是当我请求 WebGet 方法(它返回一个简单的 XML 文档)方法时,我得到了以下错误:

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

什么可能导致问题?

我的网络配置:

<system.serviceModel>
<services>
  <service name="XXXX.TSDX.UI.TsdxService">
    <endpoint 
        address="Tsdx" 
        binding="webHttpBinding" 
        bindingConfiguration="TestBinding" 
        behaviorConfiguration="RESTFriendly" 
        contract="XXXX.TSDX.UI.ITsdxService" />
  </service>
</services>
<bindings>
  <webHttpBinding>
    <binding name="TestBinding" />
  </webHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="RESTFriendly">
      <webHttp />
    </behavior>
  </endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

【问题讨论】:

    标签: wcf iis-7


    【解决方案1】:

    验证在 ASP.NET 选项卡(在 IIS 中)为您的应用程序选择了正确版本的 .NET 框架

    【讨论】:

    • 版本信息:Microsoft .NET Framework 版本:4.0.30319; ASP.NET Version:4.0.30319.1 - 看来是正确的
    • 检查你的项目的属性,你必须确保版本匹配
    • 已检查 - 是的,匹配。 :-/
    • 验证您的客户端和服务文件是否匹配(WCF 的地址部分)
    • 我正在尝试将浏览器用作客户端。这是 REST 服务。
    【解决方案2】:

    如果您在 MVC 应用程序中托管此服务,请确保添加以下行以忽略控制器路由冲突,我在挣扎了一段时间后遇到了这个问题,我发现这个答案已经解决了这个问题。

    routes.IgnoreRoute("{allsvc}", new { allsvc = @"..svc(/.*)?" });

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-06
      • 2022-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多