Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 257
SaBeR Avatar asked Dec 12 '22 09:12

SaBeR


1 Answers

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

string ip = Request.UserHostAddress;
string hostname = Request.UserHostName;
like image 125
Darin Dimitrov Avatar answered Dec 14 '22 22:12

Darin Dimitrov