c#显示服务器的配置和客户端的配置

昨天做了一个简单的显示 c#显示服务器的配置和客户端的配置的页面.

其中的html代码如下:

 

< div  align ="center" >
                
< div  class ="SysTitle" > 服务器相关信息 </ div >
                
< div >
                    
< div  class ="AdminContent1" > 服务器IP地址:
                        
< asp:Label  id ="IpOnServer"  runat ="server" > Label </ asp:Label ></ div >
                    
< div  class ="AdminContent2" > 服务器的主机名:
                        
< asp:Label  id ="ServerName"  runat ="server" > Label </ asp:Label ></ div >
                    
< div  class ="AdminContent2" > 服务器的DNS别名:
                        
< asp:Label  id ="DNS"  runat ="server" > Label </ asp:Label ></ div >
                    
< div  class ="AdminContent2" > 服务器处理请求的端口:
                        
< asp:Label  id ="Stock"  runat ="server" > Label </ asp:Label ></ div >
                    
< div  class ="AdminContent2" > 协议的名称和版本:
                        
< asp:Label  id ="XieYi"  runat ="server" > Label </ asp:Label ></ div >
                    
< div  class ="AdminContent2" > 服务器的名称和版本:
                        
< asp:Label  id ="Server_Soft"  runat ="server" > Label </ asp:Label ></ div >
                    
< div  class ="AdminContent2" > 服务器操作系统:
                        
< asp:Label  id ="OSOnServer"  runat ="server" > Label </ asp:Label ></ div >
                    
< div  class ="AdminContent2" > 脚本超时时间:
                        
< asp:Label  id ="ScriptTime"  runat ="server" > Label </ asp:Label ></ div >
                
</ div >
                
< div  class ="SysTitle" > 客户端相关信息 </ div >
                
< div  class ="AdminContent1" > IP地址:
                    
< asp:Label  id ="IpOnClient"  runat ="server" > Label </ asp:Label ></ div >
                
< div  class ="AdminContent2" > 浏览器:
                    
< asp:Label  id ="BroswerOnClient"  runat ="server" > Label </ asp:Label ></ div >
                
< div  class ="AdminContent2" > 主机名称:
                    
< asp:Label  id ="ServerNameOnClient"  runat ="server" > Label </ asp:Label ></ div >
                
< div  class ="AdminContent2" > 当前访问地址:
                    
< asp:Label  id ="UrlNow"  runat ="server" > Label </ asp:Label ></ div >
                
< div  class ="AdminContent2" > 来访网络:
                    
< asp:Label  id ="NetName"  runat ="server" > Label </ asp:Label ></ div >
            
</ div >

cs代码如下:

 

if  ( ! Page.IsPostBack) 
            
{
                
if (Int32.Parse(Session["Priority"].ToString()) > 2
                
{
                    Response.Write(
"<script>alert('对不起,您的权限不够,无权访问此页面!');top.location.href='../default.aspx'</script>");
                }

                IPHostEntry OIPHost 
= Dns.Resolve(Environment.MachineName);
                
if (OIPHost.AddressList.Length > 0
                
{
                    
this.IpOnServer.Text = OIPHost.AddressList[0].ToString();
                }
            
                
this.DNS.Text = OIPHost.HostName;
                
this.ServerName.Text = Environment.MachineName;
                
this.OSOnServer.Text = Environment.OSVersion.ToString();
                
this.Server_Soft.Text = Request.ServerVariables["SERVER_SOFTWARE"].ToString();
                
this.Stock.Text = Request.ServerVariables["SERVER_PORT"].ToString();
                
this.XieYi.Text = Request.ServerVariables["SERVER_PROTOCOL"].ToString();
                
this.ScriptTime.Text = Server.ScriptTimeout.ToString();
                
////OnClient
                this.IpOnClient.Text = Request.UserHostAddress;
                
this.ServerNameOnClient.Text = Request.UserHostName;
                
this.BroswerOnClient.Text =Request.Browser.Type;
                
this.NetName.Text = Environment.UserDomainName;
                
this.UrlNow.Text = Request.RawUrl;

 

这上面用到了1个命名空间是:using System.Net;获取服务器IP时候用到的

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值