How to get the server name using c#

Posted by Bhavanib under C# on 12/4/2012 | Points: 10 | Views : 8077 | Status : [Member] | Replies : 4
Hi Friends,

We are running one service in client system(Buddy test,DR Environment and Production environment) and sending mail if any failure occurs for some functionality.

In this mail format i want to include server name also whether the issue has come from BT,DR or Production environment.
How to handle this situation?

Waiting for your reply

Thanks,
Bhavani




Responses

Posted by: Krv on: 12/4/2012 [Member] Starter | Points: 25

Up
0
Down
Environment.MachineName

Thanks,
R.Vasanth
MCTS(SQL Server & BI)
http://bigdatatech.blogspot.com

Bhavanib, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/5/2012 [Member] Bronze | Points: 25

Up
0
Down
string Line = Environment.MachineName;

Thanks
Pavan Kumar
Mark Answer if this fits the need

Bhavanib, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajesh081725 on: 12/7/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Bhavani,

try this code

string computer_name = System.Environment.GetEnvironmentVariable("COMPUTERNAME");

Time is Gold
Thanks & Regards,
Rajesh Kumar,
9962038582.

Bhavanib, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandhyab on: 12/7/2012 [Member] Starter | Points: 25

Up
0
Down
System.Environment.MachineName identifies the server where the code resides.
System.Environment.GetEnvironmentVariable("COMPUTERNAME"); Which will return the full computer name.

Thanks & Regards

Bhavanib, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response