zoukankan      html  css  js  c++  java
  • ASP.NET获取客户端、服务器端基础信息集合

     
    1. 在ASP.NET中专用属性:
    获取服务器电脑名:Page.Server.ManchineName
    获取用户信息:Page.User
    获取客户端电脑名:Page.Request.UserHostName
    获取客户端电脑IP:Page.Request.UserHostAddress

    2. 在网络编程中的通用方法:
    获取当前电脑名:static System.Net.Dns.GetHostName()
    根据电脑名取出全部IP地址:static System.Net.Dns.Resolve(电脑名).AddressList
    也可根据IP地址取出电脑名:static System.Net.Dns.Resolve(IP地址).HostName

    3. 系统环境类的通用属性:
    当前电脑名:static System.Environment.MachineName
    当前电脑所属网域:static System.Environment.UserDomainName
    当前电脑用户:static System.Environment.UserName

    客户端IP:Page.Request.UserHostAddress;
    用户信息:Page.User;
    服务器电脑名称:Page.Server.MachineName;
    当前用户电脑名称:System.Net.Dns.GetHostName();
    当前电脑名:System.Environment.MachineName;
    当前电脑所属网域:System.Environment.UserDomainName;
    当前电脑用户:System.Environment.UserName;
    浏览器类型:Request.Browser.Browser;
    浏览器标识:Request.Browser.Id;
    浏览器版本号:Request.Browser.Version;
    浏览器是不是测试版本:Request.Browser.Beta;
    浏览器的分辨率(像素):Request["width"].ToString() + "*" + Request["height"].ToString();//1280*1024
    客户端的操作系统:Request.Browser.Platform;
    是不是win16系统:Request.Browser.Win16;
    是不是win32系统:Request.Browser.Win32;

    4.服务器端的信息:
    服务器计算机名:"http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;
    服务器IIS版本: Request.ServerVariables["Server_SoftWare"].ToString();
    服务器域名:Request.ServerVariables["SERVER_NAME"].ToString();
    服务器端口:Request.ServerVariables["Server_Port"].ToString();
    服务器IP地址:Request.ServerVariables["LOCAl_ADDR"]
    服务器脚本超时时间:(Server.ScriptTimeout / 1000).ToString() + "秒";
    服务器操作系统:Environment.OSVersion.ToString();
    本文件所在文件夹:Request.PhysicalApplicationPath;
    服务器IE版本:Registry.LocalMachine.OpenSubKey(@"SOFTWARE/Microsoft/Internet Explorer/Version Vector").GetValue("IE", "未检测到").ToString();
    系统所在文件夹:Environment.SystemDirectory.ToString();
    服务器当前时间: DateTime.Now.ToString();
    服务器的语言种类:CultureInfo.InstalledUICulture.EnglishName;
    服务器上次启动到现在已运行时间: ((Environment.TickCount / 0x3e8) / 60).ToString() + "分钟";
    CPU 类型:Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER").ToString();
    逻辑驱动器:string[] achDrives = Directory.GetLogicalDrives();
    for (int i = 0; i < Directory.GetLogicalDrives().Length - 1; i++)
    {
       achDrives.ToString();
    }
    CPU 总数:Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS").ToString();
    虚拟内存:(Environment.WorkingSet / 1024).ToString() + "M";
    .NET Framework 版本:string.Concat(new object[] { Environment.Version.Major, ".", Environment.Version.Minor, Environment.Version.Build, ".", Environment.Version.Revision });
    Asp.net所占CPU:((TimeSpan)Process.GetCurrentProcess().TotalProcessorTime).TotalSeconds.ToString("N0");
    Asp.net所占内存: ((Double)Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString("N2") + "M";
    当前Session数量:Session.Contents.Count.ToString();
    当前程序占用内存:((Double)GC.GetTotalMemory(false) / 1048576).ToString("N2") + "M";
    当前SessionID:Session.Contents.SessionID;
    当前系统用户名:Environment.UserName;
     
     
  • 相关阅读:
    操作数组可以通过Array这个类来操作(不需要考虑数组的类型!!!)
    Servlet------>jsp自定义标签SimpleTag(jsp2.0以后的方法,1-5已经淘汰了)
    Servlet------>jsp自定义标签5(标签体内容改为大写)
    Servlet------>jsp自定义标签(JSPTAG接口)
    Servlet------>jsp自定义标签4(重复标签体)
    Servlet------>jsp自定义标签3(不显示余下jsp内容)
    模块学习
    正则表达式与re模块
    模块
    迭代器与生成器
  • 原文地址:https://www.cnblogs.com/kingboy2008/p/2857508.html
Copyright © 2011-2022 走看看