get computer name

G

Guest

Heylo

I want to be able to get the computer name from my C# page. Is this
possible? Basically, I'm developing a auto-bugreport feature for an intranet
and want to know which machine sent the report. All machines are listed on
the workgroup and in AD.

Any suggestions?

Cheers


Dan
 
C

Curt_C [MVP]

Get IP, you can then reverse lookup, otherwise have you looked through the
Request.ServerVariables collection?
 
S

Steve C. Orr [MVP, MCSD]

Request.ServerVariables("REMOTE_HOST") will give you the machine name (if
available.)

Request.ServerVariables("REMOTE_ADDR") will give you the IP address of the
client machine. However, the true IP address may be masked by proxy servers
so you can't entirely rely on it being unique.
 
G

Guest

Hi guys,

Thanks for the replies. Remote Host just gives me the IP address 127.0.0.1
?? That's not right, obviously. What am I doing wrong? (Machine does have a
name, tis called "DANS" ... which is what I want to retrieve)

Cheers


Dan
 
P

Patrice

Don't test using "localhost". localhost is a special case as it is always
the PC on which you are and will give always the same "local" IP address...

If you want to test on your own OC, use its name rather than localhost...

Patrice


--
 
W

William F. Robertson, Jr.

System.Enviroment.MachineName to get the name of the machine the error
occurred on.

bill
 
G

Guest

Spot on. Thanks a lot Bill.

Just out of interest... Patrice, how did you mean dont use local host? I
wasn't using any IP addys? Just the line

Request.ServerVariables["REMOTE_HOST"];

Justwondering for future reference! :eek:)
 
P

Patrice

If you test using http://localhost/mypage.aspx,
Request.ServerVariables("REMOTE_HOST") will return always 127.0.0.1
If you test using http://mymachine/mypage.aspx, it will return the "true" IP
Address and you'll be able to resolve the IP to a name.

System.Environment.MachineName gives the name of the machine where the
application runs (ie. server side). It looks like to me you want the name of
the client side machine.

I believe you are perhaps a bit confused as you are likely testing for now,
on a single machine ?

Hope it helps.

Patrice

--

Dan Nash said:
Spot on. Thanks a lot Bill.

Just out of interest... Patrice, how did you mean dont use local host? I
wasn't using any IP addys? Just the line

Request.ServerVariables["REMOTE_HOST"];

Justwondering for future reference! :eek:)

William F. Robertson said:
System.Enviroment.MachineName to get the name of the machine the error
occurred on.

bill
 
W

William F. Robertson, Jr.

Incase Patrice doesn't reply....

I think what Patrice means is when you are on the same machine browsing as
the webserver, not all the same headers get sent over to the web server
side. IE I guess realizes that it is on the same machine and leaves out
some things. Like changing the IP address over to 127.0.0.1 instead of the
IP address of your machine.

This only is an issue when you are browsing and servering on the same
machine, if an issue at all. All my developers develop and test on the same
machine. I am sure Patrice just wanted you to be aware of it.

bill


Dan Nash said:
Spot on. Thanks a lot Bill.

Just out of interest... Patrice, how did you mean dont use local host? I
wasn't using any IP addys? Just the line

Request.ServerVariables["REMOTE_HOST"];

Justwondering for future reference! :eek:)

William F. Robertson said:
System.Enviroment.MachineName to get the name of the machine the error
occurred on.

bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top