Multiple base addresses for WCF Service

If we do not want to explicitly set address for each EndPoint in our service then we define BASE ADDRESS for the EndPoint exposed for our service


And we use it in service configuration as below,


The advantage of having base address is that, if we are changing the service URL, we need to change at only one place instead of going and changing address of each endpoint.

WCF allow us to give multiple base addresses for each type of protocol. And at the run time corresponding endpoint will take the base address.


In above configuration, we added one more base address using net.tcp protocol.

Now at endpoint configuration, we will configure it as below


At the run time WCF automatically will map base address to corresponding endpoint with matched protocol.

For reference full Web.Config will look like

 <behavior name="MyBeh">
 <serviceMetadata httpGetEnabled="true"/>
 <serviceDebug includeExceptionDetailInFaults="false"/>
 <service name="WcfService1.Service1"  behaviorConfiguration="MyBeh">
 <endpoint address=""
 <endpoint address="nete"
 binding ="netTcpBinding"
 contract ="WcfService1.IService1"/>
 <endpoint address="mex"
 <endpoint address="mex1"
 <add baseAddress="<a href="http://localhost:8181/Service1.svc/&quot;/">http://localhost:8181/Service1.svc/"/</a>>
 <add baseAddress="net.tcp://localhost:9876/Service1.svc/"/>


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at