Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

ASP.NET: Environment Details

From Wiki

Jump to: navigation, search



Summary: An example of how to view details of the web servers environment

  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
  2.     Dim sb As New StringBuilder
  3.  
  4.     sb.AppendLine("Machine Name: " & Environment.MachineName & "<br>")
  5.     sb.AppendLine("OS Version: " & Environment.OSVersion.VersionString & "<br>")
  6.     sb.AppendLine("No. of Processors: " & Environment.ProcessorCount & "<br>")
  7.     sb.AppendLine("Uptime: " & TimeSpan.FromMilliseconds(Environment.TickCount).Days & " days, ")
  8.     sb.AppendLine(TimeSpan.FromMilliseconds(Environment.TickCount).Hours & " hours, ")
  9.     sb.AppendLine(TimeSpan.FromMilliseconds(Environment.TickCount).Minutes & " minutes<br>")
  10.     sb.AppendLine("User Domain Name: " & Environment.UserDomainName & "<br>")
  11.     sb.AppendLine("Interactive User: " & Environment.UserInteractive & "<br>")
  12.     sb.AppendLine("Username: " & Environment.UserName & "<br>")
  13.  
  14.     Label1.Text = sb.ToString
  15. End Sub

Output:

  1. Machine(Name) : A100007()
  2. OS Version: Microsoft Windows NT 5.1.2600 Service Pack 2  
  3. No. of Processors: 4  
  4. Uptime: 11 days, 1 hours, 55 minutes  
  5. User Domain Name: HOME  
  6. Interactive User: True  
  7. Username() : mark.smith()


This Hack is part of the ASP.NET Hacks collection

427 Rating: 3.0/5 (10 votes cast)