473,508 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Possibly dumb question about Environment.MachineName

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
10 2252
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
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
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
> 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
"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
> 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
"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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
378
by: duncsss | last post by:
Hi, I'm using the following code to get the Machine name in an app System.Environment.MachineName On most computers this works fine but on one of our testers computers (machine is a windows...
6
1787
by: Flare | last post by:
Hi i just read: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/exceptdotnet.asp Wich is interesting reading by the way. But. I have'nt used exception very much to...
0
1049
by: Paul Duncan | last post by:
Hi, I'm using the following code to get the Machine name in an app System.Environment.MachineName On most computers this works fine but on one of our testers computers (machine is a windows...
2
2790
by: Ely | last post by:
When I call the Environment.Machinename to try to get the local machines name, I get a "Object reference not set to an instance of an object" error. This same code works fine on my local machine,...
2
4919
by: tmoffett | last post by:
I am very new to the language so please pardon my ignorance. I am writing a small console application to gather hardware inventory information. When I run the application locally all works well....
1
1300
by: Terrance | last post by:
Hello, I was wondering if someone can help me understand something. Below is some code that I got from the MS website that is suppose to authenticate for the username and password on the local...
7
1111
by: Joel Hedlund | last post by:
Hi! There's one thing about dictionaries and __hash__() methods that puzzle me. I have a class with several data members, one of which is 'name' (a str). I would like to store several of these...
3
1924
by: Depechie | last post by:
Hey guys, small question. Can I find out if the current logged on use is a local user or a domain user ? And please don't use any solution that uses String parsing... What I need is to get...
3
1541
by: J | last post by:
The following code finds the existing file when run in the development environment, but not when deployed (in IIS on the same box). Why? String myFile = @"J:\My_jpgs\The Den\jvc90-03.JPG";...
0
7333
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.