SaBeR
SaBeR

Reputation: 41

Get client's IP address and computer name?

I have an ASP.Net 4.0 application, published on a company intranet network on an IIS 7.0 server, and I want to save the client's IP address in my database. So I want to get client's IP address and computer name.

I tried methods from internet searches but I get "SERVER IP" an "SERVER NAME". I think it's logical because all methods I tried is C# code that proceed server side.

So, I think I must use client side code like JavaScript.

Does anyone have the right method to do this?

Upvotes: 4

Views: 28040

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039478

You could use the UserHostAddress and UserHostName properties on the Request object:

string ip = Request.UserHostAddress;
string hostname = Request.UserHostName;

Upvotes: 13

Related Questions