在IIS上托管WCF服务(找不到资源) [英] Hosting WCF service on IIS (The resource cannot be found)

查看:96
本文介绍了在IIS上托管WCF服务(找不到资源)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在提供WFC服务.当我从Visual Studio调试它时,一切都很好,但是当我将其部署在真实的IIS上时,却遇到了问题.

I am making WFC service. When I debug it from Visual Studio all is ok, but I've faced with problem when I deploy it on real IIS.

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

After deploying I still can get WSDL but when I request WebGet method (which returns a simple XML document) method I got the following error:

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. 

什么可能是引起问题的原因?

What can be cause of problem?

我的Web.Config:

My Web.Config:

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

推荐答案

如果您要在MVC应用中托管此服务,请确保添加以下行以忽略控制器路由冲突,经过一段时间的努力后,我遇到了这个问题已解决问题的答案.

If you are hosting this service in MVC app please make sure to add below line to ignore controller routing conflict, I had this issue after struggling for sometime I found this answer which has resolved the issue.

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

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

这篇关于在IIS上托管WCF服务(找不到资源)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆