.NET 获取服务器及客户端信息的方法

by 陈少俊 2009.11.19 11:10

1、客户端相关信息
可由Request.ServerVariables获取,下面为基本的使用内容
Request.ServerVariables.Get("APPL_PHYSICAL_PATH").ToString(); //获取物理地址
            lbscriptName.Text = Request.ServerVariables.Get("Server_Name").ToString();//获取服务器类型
            lbIp.Text = lbIp2.Text = Request.ServerVariables.Get("Local_Addr").ToString();//获取服务器IP
            lbPort.Text = Request.ServerVariables.Get("SERVER_PORT").ToString();//获取服务器端口
            lbProtocol.Text = Request.ServerVariables.Get("SERVER_PROTOCOL").ToString();//获取协议
            lbServersoftware.Text = Request.ServerVariables.Get("SERVER_SOFTWARE").ToString();//获取web服务器

具体查看方法可使用
foreach(string o in Request.ServerVaribles )
{
     Response.Write(o + "=" + Request.ServerVaribles[o] +"<br />");


2、服务器端信息
一部分由Request.ServerVaribles中获取,另外一部分可由Operating及Environment中获取。
           OperatingSystem opera = Environment.OSVersion; 
            lbSystem.Text = opera.Platform.ToString(); //服务器平台
            lbSystemOp.Text = opera.VersionString.ToString(); //版本
            lbSystemName.Text = Server.MachineName.ToString();//服务器名
            lbScript.Text = Server.ScriptTimeout.ToString();//脚本超时时间
           
            string useragent = Request.ServerVariables.Get("HTTP_USER_AGENT").ToString();
            string[] user = useragent.Split(Convert.ToChar(";"));
            lbscriptName.Text = user[6].ToString();
            lbClientSystem.Text = user[2].ToString();
            lbXpath.Text = Request.ServerVariables.Get("PATH_INFO").ToString();
           // foreach (string o in Request.ServerVariables)
           // {
           //     Response.Write(o + "=" + Request.ServerVariables[o] + "<br />");
           // }
           lbCupnum.Text = Environment.ProcessorCount.ToString(); //服务器CPU数量

Tags:

Asp.Net技术

博客评论由 Disqus 驱动

关于博主

博主——陈少俊

   曾经的我们并不相识,但是网络让我们联系了起来,人生本来就是这样,有许多的必然和偶然,我不能做太多,只 是分享我自己拥有的,看到的,听到的。我致力于网站开发,系统建设,推广自己,谢谢大家的关心和爱护。
现就职于汽车时尚传媒有限公司网络部,中国汽车时尚网:http://www.86che.com/
汽车时尚网分类说明:汽车时尚网分类中所有新闻来源于中国汽车时尚网
汽车时尚报分类说明:汽车时尚报分类中所有新闻均为汽车时尚报出刊报纸中所有内容。
汽车时尚报电子版从《汽车时尚报》第493期开始正式免费上线,具体新闻内容请查阅【汽车时尚报】分类。
联系电话:13551107754,(028)68116678
MSN:chen1989jun@hotmail.com

日历中查看

<<  February 2012  >>
MonTueWedThuFriSatSun
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

切换到大日历中浏览

按月阅读

最近的评论

评论 RSS

声明

本博所有网友评论不代表本博立场,版权归其作者所有。

© Copyright 2009-2010  All Rights Piao Blog
蜀ICP备09038546号

部件 Statistics 未找到.

There is an error in XML document (0, 0).X