1
我有一個WCF服務在www.domain.com/Service.svc上運行,我使用jQuery從我的asp.net網站連接到WCF服務。如果用戶通過www.domain.com訪問我的網站,那麼一切正常。但是,如果用戶僅使用domain.com我得到錯誤:訪問沒有www的WCF服務的問題
There was no channel actively listening at 'http://domain.com/Service.svc/get?date=2010-10-09'.
This is often caused by an incorrect address URI. Ensure that the address to which
the message is sent matches an address on which a service is listening.
在我的web.config我使用serviceHostingEnvironment標籤來獲取服務的空間商運行(它不工作,否則)。也許這是導致錯誤的原因?
這是我在web.config中system.serviceModel(我有一些問題設置Web服務所以這就是爲什麼我的web.config可能會有點凌亂:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://www.domain.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Service">
<endpoint address="" behaviorConfiguration="ServiceAspNetAjaxBehavior"
binding="webHttpBinding" bindingConfiguration="ServiceBinding" contract="Service" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="ServiceBinding" maxBufferPoolSize="1000000" maxReceivedMessageSize="1000000">
<readerQuotas maxDepth="1000000" maxStringContentLength="1000000"
maxArrayLength="1000000" maxBytesPerRead="1000000" maxNameTableCharCount="1000000" />
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
我怎樣才能使人們有可能對於我的用戶訪問我的web服務時,也只使用domain.com?
您是否嘗試將前綴更改爲'http: // domain.com'?那是幹什麼的? – Oded 2010-10-09 09:09:45
是的,但它不適用於www.domain.com。我可以添加對兩者的支持嗎? – MysterM 2010-10-09 09:13:08
你爲什麼不選擇一個,並將用戶(從另一個)重定向到你想要的? – 2010-10-09 09:15:57