How To Get Server Computer Name?
To get computer name of your web server with ASP.NET server side code, first you need to add a reference to System.Windows.Forms namespace and then to use code like this:
[ C# ]
// We
need this namespace
using
System.Windows.Forms;
public
partial class
_Default : System.Web.UI.Page
{
protected void
Page_Load(object sender,
EventArgs e)
{
string ServerName;
ServerName =
SystemInformation.ComputerName;
}
}
[ VB.NET ]
' We
need this namespace
Imports
System.Windows.Forms
Partial
Class _Default
Inherits System.Web.UI.Page
Protected Sub
Page_Load(ByVal sender
As Object, ByVal
e As System.EventArgs)
Handles Me.Load
Dim ServerName As
String
ServerName =
SystemInformation.ComputerName
End Sub
End
Class
Related articles:
1. Client Side in ASP.NET: Common Javascript Functions
2. How to Find IIS Version With ASP.NET Code?