Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF: How to get Host IP or Server Name

Tags:

wcf

I have a WCF service that is hosted via IIS on multiple web servers. I have a logging method that logs the calls to the database and I'd like to log which server the call is executing on.

Does anyone know how to get the host server name or IP address that the WCF call is executing on?

like image 647
Kevin Jensen Avatar asked Apr 17 '09 15:04

Kevin Jensen


1 Answers

Use Dns.GetHostName(), because it's much better to get the name of the computer than the host IP. Consider the case when your host computer have more than one IP address, has virtual network cards (VMWare).

like image 67
Tomas Walek Avatar answered Oct 01 '22 21:10

Tomas Walek