There's so much stuff on this online but no one seems to be able to answer this... Hopefully someone here will be!
So i have a WCF web service hosted at godaddy.com. Everything works great when i try accessing it using:
http://www.domain.com/DataService.svc
problem is when i remove the www i.e.
http://domain.com/DataService.svc
Here's my web.config servicemodel section:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="DataServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="DataServiceBehavior"
name="DataService">
<endpoint address="" binding="basicHttpBinding" contract="IDataService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
Here's my ServiceReferences.ClientConfig
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDataService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.domain.ca/DataService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IDataService" contract="Web.IDataService"
name="BasicHttpBinding_IDataService" />
</client>
</system.serviceModel>
My service is using a CustomServiceFactory
public class CustomServiceHostFactory : ServiceHostFactory
{
/// <summary>
/// A custom method to eliminate multiple base addresses from the IIS host creation process
/// </summary>
/// <param name="serviceType">The service type to be created</param>
/// <param name="baseAddresses">A list of the base addresses</param>
/// <returns>A service host</returns>
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
if (baseAddresses.Length > 1)
{
ServiceHost customServiceHost =
new ServiceHost(serviceType, baseAddresses[1]);
return customServiceHost;
}
return new ServiceHost(serviceType, baseAddresses[0]);
}
}
Basically what i would like is my WCF webservice to be reachable whether the user enters domain.com or www.domain.com into his (or her) browser.
Any help will be greatly appreciated!
ps. Running IIS 7 with ASP 3.5
Thnaks! Simon