<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ComputerDetails.aspx.cs" Inherits="ComputerName" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Computer Details</title> </head> <body> <form id="form1" runat="server"> <table cellpadding="2" cellspacing="0" border="0"> <tr> <td> Windows User: </td> <td> <asp:TextBox ID="WindowsUser" runat="server" /> </td> </tr> <tr> <td> Machine Name: </td> <td> <asp:TextBox ID="MachineName" runat="server" /> </td> </tr> <tr> <td> Machine IP: </td> <td> <asp:TextBox ID="MachineIP" runat="server" /> </td> </tr> <tr> <td valign="top"> Browser Details: </td> <td> <asp:TextBox ID="BrowserDetails" runat="server" /> </td> </tr> <tr> <td valign="top"> Date Time: </td> <td> <asp:TextBox ID="TimeStamp" runat="server" /> </td> </tr> </table> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class ComputerName : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { System.Web.HttpBrowserCapabilities browser = Request.Browser; string s = "Browser Capabilitiesn" + "Type = " + browser.Type + "n" + "Name = " + browser.Browser + "n" + "Version = " + browser.Version + "n" + "Major Version = " + browser.MajorVersion + "n" + "Minor Version = " + browser.MinorVersion + "n" + "Platform = " + browser.Platform + "n" + "Is Beta = " + browser.Beta + "n" + "Is Crawler = " + browser.Crawler + "n" + "Is AOL = " + browser.AOL + "n" + "Is Win16 = " + browser.Win16 + "n" + "Is Win32 = " + browser.Win32 + "n" + "Supports Frames = " + browser.Frames + "n" + "Supports Tables = " + browser.Tables + "n" + "Supports Cookies = " + browser.Cookies + "n" + "Supports VBScript = " + browser.VBScript + "n" + "Supports JavaScript = " + browser.EcmaScriptVersion.ToString() + "n" + "Supports Java Applets = " + browser.JavaApplets + "n" + "Supports ActiveX Controls = " + browser.ActiveXControls + "n" + "Supports JavaScript Version = " + browser["JavaScriptVersion"] + "n"; //if (browser.Browser != "IE") //{ // Response.Write("Only Internet Explorer is supported."); // Response.End(); //} //else //{ // BrowserDetails.Text = s; //} BrowserDetails.Text = browser.Browser + " " + browser.Version; string[] computer_name = System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName.Split(new Char[] { '.' }); String ecn = System.Environment.MachineName; MachineName.Text = computer_name[0].ToString().ToUpper(); System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal; WindowsUser.Text = p.Identity.Name.Replace("<Windows Domain>", ""); MachineIP.Text = Request.ServerVariables["remote_addr"]; TimeStamp.Text = DateTime.Now.ToString(); } }
Last Updated on October 26, 2015