Asp.net web service: Problems accessing without www

Posted by MysterM on Stack Overflow See other posts from Stack Overflow or by MysterM
Published on 2010-10-09T09:06:28Z Indexed on 2010/12/23 22:54 UTC
Read the original article Hit count: 219

Filed under:
|
|

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"/>
        </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?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about web-services