Possibly dumb question about Environment.MachineName

E

Edward

I've just taken over maintaining a system from a colleague who has
left. I find the following line in her code:

Dim params(2) As SqlClient.SqlParameter

params(0) = New SqlClient.SqlParameter("@UserName", pvstrUsername)
params(1) = New SqlClient.SqlParameter("@Password", pvstrPassword)
params(2) = New SqlClient.SqlParameter("@MachineName",
Environment.MachineName())

When I run the code in the debugger, I find that the value of
Environment.MachineName is the same as the name of my PC. But I'm
running this on my localhost IIS.

So, my question is: if I run this in my browser but with the
application on a different web server, what will the value of
Environment.MachineName?

Do I make myself clear? Am I as dumb as a bag of spanners?

Edward
 
E

Eliyahu Goldin

Edward,

It's a server-side code. It will produce the server's name.

Eliyahu
 
K

Kevin Spencer

Environment.MachineName does not get the name of the web server you are
runnnig on but the name of the computer you are in.

I have to disagree here. Environment.MachineName gets the name of the
machine in whose Environment the application is running. In a web
application, this would be the name of the server on which the ASP.Net
process is running. "The computer you are in" is a non-sequitor. It is not
possible for a person to be "in" a computer. If you meant by that, the
computer that the user is using, in a web application running server-side
code, that statement would be false.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Alan Ferrandiz Langley said:
Environment.MachineName does not get the name of the web server you are
runnnig on but the name of the computer you are in. You could even use it in
Windows Forms. So no matter what it will give you the name of the PC.
Check this link in MSDN for the proper definition
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemenvironmentclassmachinenametopic.asp

Alan Ferrandiz
MCT;MCSD,MCDBA
MSF Practitioner
 
A

Alan Ferrandiz Langley

Yes you are right Kevin, Environment.MachineName is going to get the name of
the computer your application is running on. Well in this case Edward is
developing his application so in this situation he will get the name of the
computer he is developing the application in. If one wants to get
information of the client computer, one would have to use the Request
object. Anyway Spanish is my mother tongue, I'm improving my English
everyday.

Alan Ferrandiz L.
MCT; MCSD; MCDBA
MSF Practitioner
Lima - Peru

Kevin Spencer said:
Environment.MachineName does not get the name of the web server you are
runnnig on but the name of the computer you are in.

I have to disagree here. Environment.MachineName gets the name of the
machine in whose Environment the application is running. In a web
application, this would be the name of the server on which the ASP.Net
process is running. "The computer you are in" is a non-sequitor. It is not
possible for a person to be "in" a computer. If you meant by that, the
computer that the user is using, in a web application running server-side
code, that statement would be false.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Alan Ferrandiz Langley said:
Environment.MachineName does not get the name of the web server you are
runnnig on but the name of the computer you are in. You could even use
it
in
Windows Forms. So no matter what it will give you the name of the PC.
Check this link in MSDN for the proper definition
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
 
K

Kevin Spencer

Mucho gusto, Alan,

Unfortunately, the Request object will only have the IP address of the
client machine. This is certainly available to the server.

Su Ingles es mucho mejor que mi espanol!

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
E

Edward

Kevin Spencer said:
Mucho gusto, Alan,

Unfortunately, the Request object will only have the IP address of the
client machine. This is certainly available to the server.

So, to sum up then. The code is running on the server. Will
Environment.MachineName return the name of the server, or the name of
the client machine on which the browser is running?

Edward
 

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

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top