Radical Development

Obtain Web Server Details With CSharp Or VB.NET

C# Example

///
/// Handles the Load event of the Page control.
///
/// The source of the event. /// The instance containing the event data. protected void Page_Load(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();

sb.AppendLine(string.Format("Machine Name: {0}{1}", Environment.MachineName, "
"));
sb.AppendLine(string.Format("OS Version: {0}{1}", Environment.OSVersion.VersionString, "
"));
sb.AppendLine(string.Format("Platform: {0}{1}", Environment.OSVersion.Platform, "
"));
sb.AppendLine(string.Format("No. of Processors: {0}{1}", Environment.ProcessorCount, "
"));
sb.AppendLine(string.Format("Uptime: {0}{1}", TimeSpan.FromMilliseconds(Environment.TickCount).Days, " days, "));
sb.AppendLine(string.Format("{0}{1}", TimeSpan.FromMilliseconds(Environment.TickCount).Hours, " hours, "));
sb.AppendLine(string.Format("{0}{1}", TimeSpan.FromMilliseconds(Environment.TickCount).Minutes, " minutes
"));
sb.AppendLine(string.Format("User Domain Name: {0}{1}", Environment.UserDomainName, "
"));
sb.AppendLine(string.Format("Interactive User: {0}{1}", Environment.UserInteractive, "
"));
sb.AppendLine(string.Format("Username: {0}{1}", Environment.UserName, "
"));

Label1.Text = sb.ToString();
}

VB.NET

'''
''' Handles the Load event of the Page control.
'''
''' The source of the event. ''' The instance containing the event data.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim sb As New StringBuilder()
?
sb.AppendLine(String.Format("Machine Name: {0}{1}", Environment.MachineName, "
"))
sb.AppendLine(String.Format("OS Version: {0}{1}", Environment.OSVersion.VersionString, "
"))
sb.AppendLine(String.Format("Platform: {0}{1}", Environment.OSVersion.Platform, "
"))
sb.AppendLine(String.Format("No. of Processors: {0}{1}", Environment.ProcessorCount, "
"))
sb.AppendLine(String.Format("Uptime: {0}{1}", TimeSpan.FromMilliseconds(Environment.TickCount).Days, " days, "))
sb.AppendLine(String.Format("{0}{1}", TimeSpan.FromMilliseconds(Environment.TickCount).Hours, " hours, "))
sb.AppendLine(String.Format("{0}{1}", TimeSpan.FromMilliseconds(Environment.TickCount).Minutes, " minutes
"))
sb.AppendLine(String.Format("User Domain Name: {0}{1}", Environment.UserDomainName, "
"))
sb.AppendLine(String.Format("Interactive User: {0}{1}", Environment.UserInteractive, "
"))
sb.AppendLine(String.Format("Username: {0}{1}", Environment.UserName, "
"))
?
Label1.Text = sb.ToString()
End Sub

Result

Machine Name: RADDEV
OS Version: Microsoft Windows NT 6.0.6000.0
Platform: Win32NT
No. of Processors: 2
Uptime: 0 days, 8 hours, 50 minutes
User Domain Name: RadDev
Interactive User: True
Username: Steven

Author: Steven Swafford

Highly motivated information technology professional with 16+ years of experience. Working as a software engineer Steven develops and maintains web based software solutions. As a skilled professional he is focused on the design and creation of software. Because communication skills are extremely important Steven continues to expand his knowledge in order to communicate clearly with all facets of business. Recently Steven has been leading efforts to standardize software development tools and technology, plans and coordinates web accessibility as applied to IT Solutions, and he is tackling application security in terms of best practices and implementation of the Security Development Life-cycle.

Comments are closed.