<%@ Page Language="C#"   %>

<%@ Register Src="Memu/InfovrsionControl.ascx" TagName="InfovrsionControl" TagPrefix="uc1" %>

<html>
<head>
<title>asp.net 双向探针：即看服务器又看自己</title>

 <link href="Css/StyleSheet.css" rel="stylesheet" type="text/css" /> 
</head>
<body topmargin="0">
<div align="center"><form runat="server">
  <table width="760" border="0" cellpadding="1" cellspacing="1" class="table">
    <tr> 
      <td  class="title" colspan="2">.NET 服务器相关信息&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2">
      <table border="0" cellpadding="0" cellspacing="2" class="Table" style="width: 100%">
            <tr> 
              <td width="20%" class="td" >服务器名称：</td>
              <td width="30%" class="td" > 
                <asp:label ID="servername" runat="server" />
                </td>
              <td width="20%" class="td" >服务器操作系统：</td>
              <td width="30%" class="td" > 
                <asp:label ID="serverms" runat="server" />
                </td>
            </tr>
            <tr> 
              <td width="20%" class="td" >服务器IP地址：</td>
              <td width="30%" class="td" > 
                <asp:label ID="serverip" runat="server" />
                </td>
              <td width="20%" class="td" >服务器域名：</td>
              <td width="30%" class="td" > 
                <asp:label ID="server_name" runat="server" />
                </td>
            </tr>
            <tr> 
              <td width="20%" class="td" >服务器IIS版本：</td>
              <td width="30%" class="td" > 
                <asp:label ID="serversoft" runat="server" />
                </td>
              <td width="20%" class="td" >.NET解释引擎版本：</td>
              <td width="30%" class="td" > 
                <asp:label ID="servernet" runat="server" />
                </td>
            </tr>
            <tr> 
              <td width="20%" class="td" >HTTPS：</td>
              <td width="30%" class="td" > 
                <asp:label ID="serverhttps" runat="server" />
                </td>
              <td width="20%" class="td" >HTTP访问端口：</td>
              <td width="30%" class="td" > 
                <asp:label ID="serverport" runat="server" />
                </td>
            </tr>
            <tr> 
              <td width="20%" class="td" >服务端脚本执行超时：</td>
              <td width="30%" class="td" > 
                <asp:label ID="serverout" runat="server" />
                秒</td>
              <td width="20%" class="td" >服务器现在时间：</td>
              <td width="30%" class="td" > 
                <asp:label ID="servertime" runat="server" />
                </td>
            </tr>
            <tr> 
              <td width="20%" class="td" >虚拟目录绝对路径：</td>
              <td colspan="3" class="td"> 
                <asp:label ID="serverppath" runat="server" />
                &nbsp; </td>
            </tr>
            <tr> 
              <td class="td" >执行文件绝对路径：</td>
              <td colspan="3" class="td"> 
                <asp:label ID="servernpath" runat="server" />
                </td>
            </tr>
            <tr> 
              <td width="20%" class="td" >虚拟目录Session总数：</td>
              <td width="30%" class="td" > 
                <asp:label ID="servers" runat="server" />
                </td>
              <td width="20%" class="td" >虚拟目录Application总数：</td>
              <td width="30%" class="td" > 
                <asp:label ID="servera" runat="server" />
                </td>
            </tr>
          </table></td>
    </tr>
    <tr> 
        <td colspan="2" class="title">
            常见组件支持情况 &nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2" style="height: 267px">
    <table border="0" cellpadding="0" cellspacing="2" class="Table" style="width: 100%">
          <tr> 
            <td width="20%" class="td" >Access数据库：</td>
            <td width="30%" class="td" > 
              <asp:label ID="serveraccess" runat="server" />
              </td>
            <td width="20%" class="td" >FSO：</td>
            <td width="30%" class="td" > 
              <asp:label ID="serverfso" runat="server" />
              </td>
          </tr>
          <tr> 
            <td width="20%" class="td" >CDONTS邮件发送：</td>
            <td width="30%" class="td" > 
              <asp:label ID="servercdonts" runat="server" />
              </td>
            <td width="20%" class="td" >JMail邮件收发：</td>
            <td width="30%" class="td" > 
              <asp:label ID="jmail" runat="server"></asp:label>
              </td>
          </tr>
          <tr> 
            <td width="20%" class="td" >ASPemail发信：</td>
            <td width="30%" class="td" > 
              <asp:label ID="aspemail" runat="server"></asp:label>
              </td>
            <td width="20%" class="td" >Geocel发信：</td>
            <td width="30%" class="td" > 
              <asp:label ID="geocel" runat="server"></asp:label>
              </td>
          </tr>
          <tr> 
            <td width="20%" class="td" >SmtpMail发信：</td>
            <td width="30%" class="td" > 
              <asp:label ID="smtpmail" runat="server"></asp:label>
              </td>
            <td width="20%" class="td" >ASPUpload文件上传:</td>
            <td width="30%" class="td" > 
              <asp:label ID="aspup" runat="server"></asp:label>
              </td>
          </tr>
          <tr> 
            <td width="20%" class="td" >ASPCN文件上传：</td>
            <td width="30%" class="td" > 
              <asp:label ID="aspcnup" runat="server"></asp:label>
              </td>
            <td width="20%" class="td" >刘云峰的文件上传组件:</td>
            <td width="30%" class="td" > 
              <asp:label ID="lyfup" runat="server"></asp:label>
              </td>
          </tr>
          <tr> 
            <td width="20%" class="td" >SoftArtisans文件管理:</td>
            <td width="30%" class="td" > 
              <asp:label ID="soft" runat="server"></asp:label>
              </td>
            <td width="20%" class="td" >Dimac文件上传:</td>
            <td width="30%" class="td" > 
              <asp:label ID="dimac" runat="server"></asp:label>
              </td>
          </tr>
          <tr> 
            <td width="20%" class="td" >Dimac的图像读写组件:</td>
            <td width="30%" class="td" > 
              <asp:label ID="dimacimage" runat="server"></asp:label>
              </td>
            <td width="20%" class="td" >自定义组件查询：</td>
            <td width="30%" class="td" > <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="72%"> 
                    <asp:textbox ID="zujian" Rows="1" runat="server" TextMode="SingleLine" style="border-style:solid;border-color:black;border-width:1px"/>
                    </td>
                  <td width="28%"> 
                    <asp:button ID="ckzu" runat="server" Text="检测" OnClick="chkzujian"  />
                    </td>
                </tr>
              </table></td>
          </tr>
          <tr> 
            <td colspan="4" class="td">请正确输入你要检测的组件的ProgId或ClassId。<br>
              
              <asp:label ID="l001" runat="server" />
              </td>
          </tr>
        </table></td>
    </tr>
    <tr> 
      <td class="title" colspan="2">浏览者相关信息&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2">
      
      
      <table border="0" cellpadding="0" cellspacing="2" class="Table" style="width: 100%">
            <tr> 
              <td width="20%" class="td" >浏览者ip地址：</td>
              <td width="30%" class="td" > 
                <asp:label ID="cip" runat="server"></asp:label>
                </td>
              <td width="20%" class="td" >浏览者操作系统：</td>
              <td width="30%" class="td" > 
                <asp:label ID="ms" runat="server" /></td>
            </tr>
            <tr> 
              <td width="20%" class="td" >浏览器：</td>
              <td width="30%" class="td" > 
                <asp:label ID="ie" runat="server" /></td>
              <td width="20%" class="td" >浏览器版本：</td>
              <td width="30%" class="td" > 
                <asp:label ID="vi" runat="server" /></td>
            </tr>
            <tr> 
              <td width="20%" class="td" >JavaScript:</td>
              <td width="30%" class="td" > 
                <asp:label ID="javas" runat="server" /></td>
              <td width="20%" class="td" >VBScript:</td>
              <td width="30%" class="td" > 
                <asp:label ID="vbs" runat="server" /></td>
            </tr>
            <tr> 
              <td width="20%" class="td" >JavaApplets:</td>
              <td width="30%" class="td" > 
                <asp:label ID="javaa" runat="server" /></td>
              <td width="20%" class="td" >Cookies:</td>
              <td width="30%" class="td" > 
                <asp:label ID="cookies" runat="server" /></td>
            </tr>
            <tr> 
              <td class="td" >语言：</td>
              <td class="td"> 
                <asp:label ID="cl" runat="server"></asp:label>
                </td>
              <td class="td" >Frames（分栏）:</td>
              <td class="td"> 
                <asp:label ID="frames" runat="server" /></td>
            </tr>
          </table></td>
    </tr>
    <tr> 
      <td class="title" colspan="2" >执行效率相关情况&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2">
      
<table border="0" cellpadding="0" cellspacing="2" class="Table" style="width: 100%">      
          <tr> 
            <td width="20%" class="td" >本页执行时间：</td>
            <td width="30%" class="td" > 
              <asp:label ID="runtime" runat="server" />
              毫秒</td>
            <td width="20%" height="21" class="td" >1000万次加法循环测试：</td>
            <td width="30%" class="td" > 
              &nbsp;<asp:button ID="for1000" runat="server"  OnClick="turn_chk" Text="测试" />
              <asp:label ID="l1000" runat="server"></asp:label>
              </td>
          </tr>
          <tr> 
            <td height="34" colspan="4" class="td">欢迎提供其他主机的执行时间做参考。请写信给我，谢谢！</td>
          </tr>
        </table></td>
    </tr>
  </table>
   <uc1:InfovrsionControl ID="InfovrsionControl1" runat="server" />
</form>
</div>
</body>
</html>
<script language="C#" runat="server">
public void Page_Load(Object sender,EventArgs e){
Response.Expires = 0;
Response.CacheControl = "no-cache";
if (!Page.IsPostBack){


//取得页面执行开始时间
 DateTime stime=DateTime.Now;
 
 
//取得服务器相关信息
 servername.Text=Server.MachineName;
 serverip.Text=Request.ServerVariables["LOCAL_ADDR"];
 server_name.Text=Request.ServerVariables["SERVER_NAME"];
 
 //以下就是取值不准的地方，因为用了HTTP_USER_AGENT当做服务器信息。
 //1.0 final 使用Environment类属性，彻底解决了这一问题
 //char[] de = {';'};
 //string allhttp=Request.ServerVariables["HTTP_USER_AGENT"].ToString();
 //string[] myFilename = allhttp.Split(de);
 //servernet.Text=myFilename[myFilename.Length-1].Replace(")"," ");
int build, major, minor,revision;
build=Environment.Version.Build;
major=Environment.Version.Major;
minor=Environment.Version.Minor;
revision=Environment.Version.Revision;
 servernet.Text=".NET CLR  "+major +"."+ minor + "." + build+"."+revision;
 serverms.Text=Environment.OSVersion.ToString();
 //服务器端浏览器版本暂时不知道怎么取得，原有不准，故删除
 //1.0 final 修改
 //serverie.Text=myFilename[1];
 
 serversoft.Text=Request.ServerVariables["SERVER_SOFTWARE"];
 serverport.Text=Request.ServerVariables["SERVER_PORT"];
 serverout.Text=Server.ScriptTimeout.ToString();
 //语言应该是浏览者信息，1.0 final 修改
cl.Text=Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"];
 servertime.Text=DateTime.Now.ToString();
 serverppath.Text=Request.ServerVariables["APPL_PHYSICAL_PATH"];
 servernpath.Text=Request.ServerVariables["PATH_TRANSLATED"];
 serverhttps.Text=Request.ServerVariables["HTTPS"];
 if (chkobj("ADODB.RecordSet")){
 serveraccess.Text="支持";}
 else {serveraccess.Text="不支持";}
 if (chkobj("Scripting.FileSystemObject")){
 serverfso.Text="支持";}
 else {serverfso.Text="不支持";}
 if (chkobj("CDONTS.NewMail")){
 servercdonts.Text="支持";}
 else {servercdonts.Text="不支持";}
 servers.Text=Session.Contents.Count.ToString();
 servera.Text=Application.Contents.Count.ToString();
 
//0.1版添加的组件验证，原有组件并未转移过来，请原谅。 
 if (chkobj("JMail.SmtpMail")){
 jmail.Text="支持";}
 else {jmail.Text="不支持";}
 
 if (chkobj("Persits.MailSender")){
 aspemail.Text="支持";}
 else {aspemail.Text="不支持";}

 if (chkobj("Geocel.Mailer")){
 geocel.Text="支持";}
 else {geocel.Text="不支持";}
 
 if (chkobj("SmtpMail.SmtpMail.1")){
 smtpmail.Text="支持";}
 else {smtpmail.Text="不支持";}
 
 if (chkobj("Persits.Upload.1")){
 aspup.Text="支持";}
 else {aspup.Text="不支持";}

 if (chkobj("aspcn.Upload")){
 aspcnup.Text="支持";}
 else {aspcnup.Text="不支持";}

 if (chkobj("LyfUpload.UploadFile")){
 lyfup.Text="支持";}
 else {lyfup.Text="不支持";}
 
 if (chkobj("SoftArtisans.FileManager")){
 soft.Text="支持";}
 else {soft.Text="不支持";}

 if (chkobj("w3.upload")){
 dimac.Text="支持";}
 else {dimac.Text="不支持";}
 
 if (chkobj("W3Image.Image")){
 dimacimage.Text="支持";}
 else {dimacimage.Text="不支持";}

//取得用户浏览器信息
 HttpBrowserCapabilities bc= Request.Browser;
 ie.Text = bc.Browser.ToString();
 cookies.Text = bc.Cookies.ToString();
 frames.Text = bc.Frames.ToString();
 javaa.Text = bc.JavaApplets.ToString();
 javas.Text = bc.JavaScript.ToString();
 ms.Text = bc.Platform.ToString();
 vbs.Text = bc.VBScript.ToString();
 vi.Text = bc.Version.ToString();
 
 //取得浏览者ip地址,1.0 final 加入
cip.Text = Request.ServerVariables["REMOTE_ADDR"];
 
//取得页面执行结束时间
 DateTime etime=DateTime.Now;
 
 
//计算页面执行时间
  runtime.Text=((etime-stime).TotalMilliseconds).ToString();
}
}

//组件支持验证代码

bool chkobj(string obj){
    try {
        object meobj = Server.CreateObject(obj);
        return(true);
     }
     catch 
     {
        return(false);
     }
}

//100万次循环测试，由0.1sn bulid 021203开始加入

public void turn_chk(Object Sender,EventArgs e){
DateTime ontime=DateTime.Now;
int sum=0;
for (int i=1;i<=10000000;i++){
sum=sum+i;
}
DateTime endtime=DateTime.Now;
l1000.Text=((endtime-ontime).TotalMilliseconds).ToString()+"毫秒";
}

//自定义组件检测0.1版加入

public void chkzujian(Object Sender,EventArgs e){
string obj=zujian.Text;
 if (chkobj(obj)){
 l001.Text="检测结果：支持组件"+obj;}
 else {l001.Text="检测结果：不支持组件"+obj;}
}
</script>