Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the server machine name in ASP.NET MVC?

Tags:

.net

asp.net

I have some code that generates an email and I want to include the actual server machine name that is running in the body of the email. (It's a clustered web environment, so I want to find out what actual machine is sending the email.)

I know I can use Request.Url.AbsoluteUri, but that gives me the URL (like www.mysite.com/MyController/Action) instead of the raw actual machine name - which might be MACH3234k323).

Is there a way that I can get the actual server machine's name?

like image 925
leora Avatar asked Dec 23 '11 04:12

leora


2 Answers

Use System.Environment.MachineName

like image 117
Tomislav Markovski Avatar answered Sep 17 '22 18:09

Tomislav Markovski


The name of the machine will be here:

System.Environment.MachineName 
like image 20
Chris Adams Avatar answered Sep 21 '22 18:09

Chris Adams