I have wcf service which running with http and net.tcp protocol on IIS. Now I want to get live IP address with port that is assigned to them respectively. Furthermore,I want it in wcf service project. Please give your suggestion.
Asked
Active
Viewed 639 times
0
-
http://stackoverflow.com/questions/646525/getting-the-ip-address-of-server-in-asp-net – Mahabub Rabbani Sep 06 '16 at 05:08
-
I want to be 6' tall – Sep 06 '16 at 05:55
1 Answers
0
When you set up your WCF service using a web.config file, you specify the port as shown in the web.config below in the baseAddresses
element:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="ServiceClassName">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:12345/ServiceClassName"/>
</baseAddresses>
</host>
<endpoint address=""
binding="netTcpBinding"
contract="ServiceInterfaceName" />
</service>
</services>
</system.serviceModel>
</configuration>
The IP address is a bit more tricky. Is there a reason that the IP address is not known at runtime or is there a specific reason that you cannot use the host name to connect to your service?

João Lourenço
- 736
- 5
- 8
-
definately.this is one approach but in this approach I required to change base address whenever my service port or ip changed. but what I mean is that is there any approach where I can get live IP addresses of all assigned protocol like http,net.tcp in wcf project which running using some class like (Dns.GetHostAddresses) – Amit Bhatt Sep 06 '16 at 05:24
-
That is correct. Remember that there is a separation between development and deployment. The configuration of hostnames etc is done in the deployment step. How often is the port for your WCF service changing anyway? – João Lourenço Sep 06 '16 at 05:29
-
you are surely right. but I am looking for a way where nothing is hard code so. I admire your suggestion. thanks – Amit Bhatt Sep 06 '16 at 05:43
-