views:

13

answers:

1

I have a Asp.net web service running on www.domain.com/Service.svc that I connect to using jQuery from my asp.net website. Everything works perfect if the user access my website with www.domain.com. But if the user uses only domain.com I get error:

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.

In my web.config I use the serviceHostingEnvironment tag to get the service running on my webhost (it doesn't work otherwise). Maybe this is what causes the error?

Here is my system.serviceModel in web.config (I had some problems setting up the web service so that's why my web.config might be a bit messy:

<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"/&gt;
        </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>

How can I make it possible for my users to access my webservice also when using only domain.com?

A: 

Does your server have IIS 7.5 capabilities? Have a look at the URL Rewrite 2.0 Module and its canonical hostname rewrite rule. Should be exactly what you are looking for

citronas