没有.svc扩展名的WCF端点地址

时间:2012-10-04 19:00:38

标签: wcf configuration iis-7.5

我已启动并运行WCF服务但今天我想如果我从realative地址中删除.svc扩展并以这种方式访问​​我的服务怎么办? net.tcp:// serveraddress / services / service我但是一改变配置文件程序就没有启动。此程序和服务是使用.NET 4.0开发的,WCF 4广告服务本身托管在IIS 7.5中

可以在IIS中托管服务时以这种方式访问​​服务吗?

2 个答案:

答案 0 :(得分:1)

这可能是IIS中处理程序的问题。我还使用无扩展的WCF服务,并修改了我的web.config文件以使其工作。将其添加到您的web.config以查看它是否有帮助:

<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
  <remove name="UrlRoutingModule" />
  <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>

<handlers> 
<remove name="svc-Integrated-4.0" />
<add name="svc-Integrated-4.0" path="*" verb="*" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
      <add 
        name="UrlRoutingHandler" 
        preCondition="integratedMode" 
        verb="*" path="UrlRouting.axd" 
        type="System.Web.HttpForbiddenHandler, System.Web,  
          Version=2.0.0.0, Culture=neutral,  
          PublicKeyToken=b03f5f7f11d50a3a"/> 
    </handlers> 
</system.webServer>

答案 1 :(得分:0)

我在没有svc文件的情况下托管了我的WCF服务。我在Global.asax文件的Application_Start方法中将ServiceRoute添加到RouteTable。

protected void Application_Start(object sender, EventArgs e)
{
    RouteTable.Routes.Add(new ServiceRoute("AdminDataService", new WebServiceHostFactory(), typeof(AdminService)));
    RouteTable.Routes.Add(new ServiceRoute("AuthenticationService", new WebServiceHostFactory(), typeof(AuthenticationService)));
}