user175084
user175084

Reputation: 4630

get remote Ip address or machine name

I have my GUI files published on a server... this server is where the IIS is running..

Now i access my GUI from a remote machine. how can i get this machines IP address or username.

I get the server name of the machine using this code:

string svrName = System.Net.Dns.GetHostName();

please help thanks...

maybe i was not clear enough:

Let me explain again..

there are 2 machines A and B.. A is where i have my published files for the GUI and also the IIS... the above code gives me the name of machine A

now i call the GUI from machine B. and i want the name of machine B

Upvotes: 1

Views: 10211

Answers (2)

To get a remote user's IP from Asp.Net, you can use Request.ServerVariables["REMOTE_ADDR"] or Request.UserHostAddress.

The Request object should be available anywhere in your ASPX page.

I don't think it's possible to reliably get the hostname through ServerVariables.

Upvotes: 7

David
David

Reputation: 218828

Assuming I understand what you're asking, System.Web.HttpContext.Current.Request will give your server-side code lots of information about the client making the request.

Upvotes: 3

Related Questions