2012-10-04 68 views
1

我有WCF服務啓動並運行,但今天我想如果我從相關地址中刪除.svc擴展並以這種方式訪問​​我的服務? net.tcp:// serveraddress/services/service我但只要我改變配置文件程序沒有啓動。這個程序和服務是使用.NET 4.0開發的,WCF 4廣告服務本身託管在IIS 7.5中。WCF端點地址沒有.svc擴展

有可能以這種方式訪問​​服務,同時讓它們在IIS中託管?

+0

您是否嘗試在IIS中更改應用程序的默認頁面以指向svc文件,或者您是否試圖避免所有這些? – iMortalitySX

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

' <規則名稱= 「SmapleServiceRule」 stopProcessing = 「真」> <匹配URL = 「^ virtualpath> <動作類型=」 重寫」 URL = 「servicename.svc」/> ' 是否正確的方式tu重寫?爲什麼我應該刪除並添加處理程序? –

+0

我仍然無法達到預期的結果有人可以解釋如何配置? –

+0

有沒有人知道要做到這一點?我的問題是,我是使用net.tcp綁定。如果在http請求中引用它,它可以工作,但不適用於net.tcp –

0

我承載了我的WCF服務沒有svc文件。我在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))); 
}