关闭

生成.NET 服务器相关信息 页面

260人阅读 评论(0) 收藏 举报

前台:
<body id="countid">
    <div align="center">
        <form id="form1" runat="server">
        <table width="100%" border="0" cellpadding="1" cellspacing="1" style="border: 1px solid Black;
            font-family: Verdana; border-collapse: collapse; height: 540px;">
            <tr>
                <td bgcolor="#5c90d9" colspan="2" class="jjy" align="center">
                    <font color="#FFFFFF">.NET 服务器相关信息</font>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000"
                        style="border-color: Black; border-width: 1px; border-style: solid; font-family: Verdana;
                        border-collapse: collapse;">
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">服务器名称:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="servername" runat="server" />
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">服务器操作系统:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="serverms" runat="server" />
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">服务器IP地址:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="serverip" runat="server" />
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">服务器域名:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="server_name" runat="server" />
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">服务器IIS版本:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="serversoft" runat="server" />
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">.NET解释引擎版本:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="servernet" runat="server" />
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">HTTPS:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="serverhttps" runat="server" />
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">HTTP访问端口:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="serverport" runat="server" />
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">服务端脚本执行超时:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="serverout" runat="server" />
                                    秒</font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">服务器现在时间:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="servertime" runat="server" />
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">虚拟目录Session总数:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="servers" runat="server" />
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">虚拟目录Application总数:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="servera" runat="server" />
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">虚拟目录绝对路径:</font>
                            </td>
                            <td colspan="3" align="left">
                                <font size="2">
                                    <asp:Label ID="serverppath" runat="server" />
                                </font><font size="2">  </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">执行文件绝对路径:</font>
                            </td>
                            <td colspan="3" align="left">
                                <font size="2">
                                    <asp:Label ID="servernpath" runat="server" />
                                </font>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2" bgcolor="#5c90d9" class="jjy" align="center">
                    <font color="#FFFFFF">常见组件支持情况</font>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000"
                        style="border-color: Black; border-width: 1px; border-style: solid; font-family: Verdana;
                        border-collapse: collapse;">
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">Access数据库:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="serveraccess" runat="server" />
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">FSO:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="serverfso" runat="server" />
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">CDONTS邮件发送:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="servercdonts" runat="server" />
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">JMail邮件收发:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="jmail" runat="server"></asp:Label>
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">ASPemail发信:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="aspemail" runat="server"></asp:Label>
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">Geocel发信:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="geocel" runat="server"></asp:Label>
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">SmtpMail发信:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="smtpmail" runat="server"></asp:Label>
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">ASPUpload文件上传:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="aspup" runat="server"></asp:Label>
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">ASPCN文件上传:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="aspcnup" runat="server"></asp:Label>
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">文件上传组件:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="lyfup" runat="server"></asp:Label>
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">SoftArtisans文件管理:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="soft" runat="server"></asp:Label>
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">Dimac文件上传:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="dimac" runat="server"></asp:Label>
                                </font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">Dimac的图像读写组件:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="dimacimage" runat="server"></asp:Label>
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">自定义组件查询:</font>
                            </td>
                            <td>
                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td colspan="2">
                                            <font size="2">
                                                <asp:TextBox ID="zujian" Rows="1" runat="server" TextMode="SingleLine" Style="border-style: solid;
                                                    border-color: black; border-width: 1px" />
                                            </font><font size="2">
                                                <asp:Button ID="ckzu" runat="server" Text="检测" OnClick="chkzujian" Style="background-color: #75c1ff;
                                                    border-color: black; border-width: 1px" />
                                            </font>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4">
                                <font size="2">请正确输入你要检测的组件的ProgId或ClassId。<br />
                                    <font color="Red">
                                        <asp:Label ID="l001" runat="server" />
                                    </font></font>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td bgcolor="#5c90d9" colspan="2" class="jjy" align="center">
                    <font color="#FFFFFF">浏览者相关信息</font>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000"
                        style="border-color: Black; border-width: 1px; border-style: solid; font-family: Verdana;
                        border-collapse: collapse;">
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">浏览者ip地址:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="cip" runat="server"></asp:Label>
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">浏览者操作系统:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="ms" runat="server" /></font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">浏览器:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="ie" runat="server" /></font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">浏览器版本:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="vi" runat="server" /></font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">JavaScript:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="javas" runat="server" /></font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">VBScript:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="vbs" runat="server" /></font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">JavaApplets:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="javaa" runat="server" /></font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">Cookies:</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="cookies" runat="server" /></font>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">语言:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="cl" runat="server"></asp:Label>
                                </font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">Frames(分栏):</font>
                            </td>
                            <td>
                                <font size="2">
                                    <asp:Label ID="frames" runat="server" /></font>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td bgcolor="#5c90d9" colspan="2" class="jjy" align="center">
                    <font color="#FFFFFF">执行效率相关情况</font>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="Black"
                        rules="all" class="ty" style="border-color: Black; border-width: 1px; border-style: solid;
                        font-family: Verdana; border-collapse: collapse;">
                        <tr>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">本页执行时间:</font>
                            </td>
                            <td style="width: 115px">
                                <font size="2">
                                    <asp:Label ID="runtime" runat="server" />
                                    毫秒</font>
                            </td>
                            <td bgcolor="#f2f2f2" style="width: 170px" align="right">
                                <font size="2">1000万次加法循环测试:</font>
                            </td>
                            <td>
                                <font size="2"> <asp:Button ID="for1000" runat="server" OnClick="turn_chk" Text="测试"
                                    Style="background-color: #75c1ff; border-color: black; border-width: 1px" />
                                    <asp:Label ID="l1000" runat="server"></asp:Label>
                                </font>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        </form>
    </div>
</body>
 
 
 
 
 
 
 
<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>
vs2010
转之:http://blog.csdn.net/cmx454870485/article/details/7004825


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:67332次
    • 积分:1201
    • 等级:
    • 排名:千里之外
    • 原创:51篇
    • 转载:19篇
    • 译文:0篇
    • 评论:9条
    文章分类