Click here to Skip to main content
15,908,834 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All,

Assume there are two systems System1 & System2. System1 - Windows XP and System2 - Linux. I have installed a WPF application in System1. User who is using the System2 will launch the WPF application thru Remote Connection with System1.

Thru WPF application, I can read the IP address and Windows Login Name for the System1 thru the following codes.

C#
private String GetIP()
        {
            string strHostName = "";
            strHostName = System.Net.Dns.GetHostName();
            IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName);
            IPAddress[] addr = ipEntry.AddressList;
            return addr[0].ToString();
        }

String WinUserName_withNetwork = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
String WinUserNameOnly = System.Environment.UserName;



Please help me how to read the IP address and Windows login name for System2.
Posted
Updated 4-Jun-13 1:46am
v2

Try this:

C#
string goog = "www.google.com";
IPAddress[] addresslist = Dns.GetHostAddresses(goog);

foreach (IPAddress theaddress in addresslist)
{
   Console.WriteLine(theaddress.ToString());
}
 
Share this answer
 
v2
Try with Request.ServerVariables["REMOTE_ADDR"] or Request.UserHostAddress.

The Request object should be available anywhere in your ASPX page.
 
Share this answer
 
you can try this
C#
strIPAddress = Request.ServerVariables("LOCAL_ADDR")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900