WCF Service Endpoints vs Host Base address

when you use base address, you don't need to provide absolute URI for your endpoints, for example, you may use address="basic" in the endpoint configuration section, this means the address for that endpoint is http://localhost:8080/EvalsService/basic.


When you leave the endpoint address empty, it means that endpoint will simply use the corresponding base address for its endpoint address. Alternatively, you can configure the base address as the absolute path of your service, or as a better approach, write relative addresses for your endpoints.

When you host your services on IIS, service base address is determined by the IIS virtual directory along with the .svc file.

Suppose you have a file named calc.svc and you place it in a virtual directory that corresponds to 'http://localhost:8080/calcservice'. The base address for this service will be 'http://localhost:8080/calcservice/calc.svc'.

IIS forces your endpoints to use this base address determined according to your service deployment path. If you specify a different base address then the corresponding virtual directory, you'll get an exception.

Consider the configuration below;

<configuration>
    <system.serviceModel>
        <services>
            <service name="CalculatorService">
              <!-- base address determined by IIS virtual directory -->
              <endpoint binding="basicHttpBinding" contract="ISimpleMath"/>
              <endpoint address="secure" binding="wsHttpBinding" contract="ISimpleMath"/>
              <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        ...

... the address of the first endpoint becomes the same as the base address ('http://localhost:8080/calcservice/calc.svc') since I left the endpoint address empty. The address of the second endpoint becomes the combination of the base address appended with "secure", like this: 'http://localhost:8080/calcservice/calc.svc/secure'. And the address of the "mex" endpoint is 'http://localhost:8080/calcservice/calc.svc/mex'. This can seem a bit strange to some people since the relative portion of the address is added to the right of the file name, but you have to remember that calc.svc is part of the base address so it has to work this way.

Though you can not navigate to the "../mex" or "../secure" URLs through browser, they are actually active and clients can consume these addresses.

Client behavior

Clients have no awareness of the service’s base address and have no need to support something similar on their side of the wire. As a result, you won’t find anything related to base addresses in the client-side object model or the configuration section. Clients simply choose a particular endpoint, which always comes configured with an absolute address, and that absolute address determines the address it will use during transmission.

Above information mostly extracted from Aaron Skonnard's excellent article on msdn. I strongly suggest you read it to get the fundamentals behind WCF addressing.


When you host the WCF service on IIS, the base address can only be the URL to the .svc file. If you specify any other base address, it's ignored. You can still specify the relative URI for your endpoints, such as address="basic" or address = "ws". Then the address on the endpoint becomes <URL to the .svc file>/basic and <URL to the .svc file>/ws in this case.