By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,853 Members | 842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,853 IT Pros & Developers. It's quick & easy.

Possibly dumb question about Environment.MachineName

P: n/a
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
--
The reading group's reading group:
http://www.bookgroup.org.uk
Nov 18 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Edward,

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

Eliyahu

"Edward" <te********@hotmail.com> wrote in message
news:25*************************@posting.google.co m...
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
--
The reading group's reading group:
http://www.bookgroup.org.uk

Nov 18 '05 #2

P: n/a
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/de...us/cpref/html/
frlrfsystemenvironmentclassmachinenametopic.asp

Alan Ferrandiz
MCT;MCSD,MCDBA
MSF Practitioner

"Edward" <te********@hotmail.com> escribió en el mensaje
news:25*************************@posting.google.co m...
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
--
The reading group's reading group:
http://www.bookgroup.org.uk

Nov 18 '05 #3

P: n/a
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/de...us/cpref/html/
frlrfsystemenvironmentclassmachinenametopic.asp

Alan Ferrandiz
MCT;MCSD,MCDBA
MSF Practitioner

"Edward" <te********@hotmail.com> escribió en el mensaje
news:25*************************@posting.google.co m...
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
--
The reading group's reading group:
http://www.bookgroup.org.uk

Nov 18 '05 #4

P: n/a
> 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" <af********@online.labroe.com> wrote in message
news:e7**************@TK2MSFTNGP11.phx.gbl... 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/de...us/cpref/html/ frlrfsystemenvironmentclassmachinenametopic.asp

Alan Ferrandiz
MCT;MCSD,MCDBA
MSF Practitioner

"Edward" <te********@hotmail.com> escribió en el mensaje
news:25*************************@posting.google.co m...
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
--
The reading group's reading group:
http://www.bookgroup.org.uk


Nov 18 '05 #5

P: n/a
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:<#B*************@TK2MSFTNGP11.phx.gbl>...
Edward,

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

Eliyahu


Thanks. I thought it was.

Edward
Nov 18 '05 #6

P: n/a
> 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" <af********@online.labroe.com> wrote in message
news:e7**************@TK2MSFTNGP11.phx.gbl... 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/de...us/cpref/html/ frlrfsystemenvironmentclassmachinenametopic.asp

Alan Ferrandiz
MCT;MCSD,MCDBA
MSF Practitioner

"Edward" <te********@hotmail.com> escribió en el mensaje
news:25*************************@posting.google.co m...
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
--
The reading group's reading group:
http://www.bookgroup.org.uk


Nov 18 '05 #7

P: n/a
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:<#B*************@TK2MSFTNGP11.phx.gbl>...
Edward,

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

Eliyahu


Thanks. I thought it was.

Edward
Nov 18 '05 #8

P: n/a
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" <ks******@takempis.com> escribió en el mensaje
news:e3**************@TK2MSFTNGP10.phx.gbl...
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" <af********@online.labroe.com> wrote in message
news:e7**************@TK2MSFTNGP11.phx.gbl...
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/de...us/cpref/html/ frlrfsystemenvironmentclassmachinenametopic.asp

Alan Ferrandiz
MCT;MCSD,MCDBA
MSF Practitioner

"Edward" <te********@hotmail.com> escribió en el mensaje
news:25*************************@posting.google.co m...
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
--
The reading group's reading group:
http://www.bookgroup.org.uk



Nov 18 '05 #9

P: n/a
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.

"Alan Ferrandiz Langley" <af********@online.labroe.com> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...
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" <ks******@takempis.com> escribió en el mensaje
news:e3**************@TK2MSFTNGP10.phx.gbl...
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" <af********@online.labroe.com> wrote in message
news:e7**************@TK2MSFTNGP11.phx.gbl...
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/de...us/cpref/html/
frlrfsystemenvironmentclassmachinenametopic.asp

Alan Ferrandiz
MCT;MCSD,MCDBA
MSF Practitioner

"Edward" <te********@hotmail.com> escribió en el mensaje
news:25*************************@posting.google.co m...
> 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
> --
> The reading group's reading group:
> http://www.bookgroup.org.uk



Nov 18 '05 #10

P: n/a
"Kevin Spencer" <ks******@takempis.com> wrote in message news:<#d**************@tk2msftngp13.phx.gbl>...
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
Nov 18 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.