我在www.domain.com/Service.svc上运行了一个WCF服务,我使用我的asp.net网站上的jQuery连接到该服务。如果用户通过www.domain.com访问我的网站,一切都很完美。但如果用户只使用domain.com,我会收到错误:
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标记来获取在我的webhost上运行的服务(否则它不起作用)。也许这是导致错误的原因?
这是我在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>
如果仅使用domain.com,我如何才能让我的用户访问我的网络服务?
答案 0 :(得分:0)
您的服务器是否具有IIS 7.5功能?查看URL Rewrite 2.0 Module及其规范主机名重写规则。应该正是您正在寻找的