Ejemplo n.º 1
0
    private void Page_Load(Object sender, EventArgs e)
    {
        // <Snippet1>
        HttpClientCertificate cs = Request.ClientCertificate;

        Response.Write("ClientCertificate Settings:<br>");
        Response.Write("Certificate = " + cs.Certificate + "<br>");
        Response.Write("Cookie = " + cs.Cookie + "<br>");
        Response.Write("Flags = " + cs.Flags + "<br>");
        Response.Write("IsPresent = " + cs.IsPresent + "<br>");
        Response.Write("Issuer = " + cs.Issuer + "<br>");
        Response.Write("IsValid = " + cs.IsValid + "<br>");
        Response.Write("KeySize = " + cs.KeySize + "<br>");
        Response.Write("SecretKeySize = " + cs.SecretKeySize + "<br>");
        Response.Write("SerialNumber = " + cs.SerialNumber + "<br>");
        Response.Write("ServerIssuer = " + cs.ServerIssuer + "<br>");
        Response.Write("ServerSubject = " + cs.ServerSubject + "<br>");
        Response.Write("Subject = " + cs.Subject + "<br>");
        Response.Write("ValidFrom = " + cs.ValidFrom + "<br>");
        Response.Write("ValidUntil = " + cs.ValidUntil + "<br>");
        Response.Write("What's this = " + cs.ToString() + "<br>");

        // </Snippet1>
    }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write("您的IP地址为:" + IPAddress + "<br/>");//输出至页面
            //System.Diagnostics.Debug.WriteLine("您的IP地址为:" + IPAddress);//输出值debug

            //获取当前请求的虚拟路径
            //Label1.Text = Request.Path.ToString();
            //获取远程客户端的ip地址
            //Label1.Text = Request.UserHostAddress;
            //获取远程客户端的DNS名称
            //Label1.Text = Request.UserHostName;


            //获取远程客户端的浏览器特性 Browser属性
            Label1.Text = Request.Browser.ToString();

            //获取浏览器特性名称
            Response.Write("浏览器类型名称:" + Request.Browser["Browser"] + "<br/>");
            Response.Write("浏览器版本:" + Request.Browser["Version"] + "<br/>");
            Response.Write("浏览器主版本:" + Request.Browser["MajorVersion"] + "<br/>");
            Response.Write("浏览器次版本:" + Request.Browser["MinorVersion"] + "<br/>");
            Response.Write("是否支持框架功能:" + Request.Browser["Frames"] + "<br/>");
            Response.Write("是否支持表格功能:" + Request.Browser["Tables"] + "<br/>");
            Response.Write("是否支持Cookies:" + Request.Browser["Cookies"] + "<br/>");
            Response.Write("是否支持VBScript:" + Request.Browser["VBScript"] + "<br/>");
            Response.Write("是否支持Java小程序:" + Request.Browser["JavaApplets"] + "<br/>");
            Response.Write("是否支持ActiveX控件:" + Request.Browser["ActiveXControls"] + "<br/>");


            //获取 Web 服务器变量的集合。
            //Response.Write("客户端浏览器所发出的所有HTTP标题文件:" + Request.ServerVariables["ALL_HTTP"] + "<br/>");
            Response.Write("发送到客户端的文件长度:" + Request.ServerVariables["CONTENT_LENGTH"] + "<br/>");
            Response.Write("发送到客户端的文件类型:" + Request.ServerVariables["CONTENT_TYPE"] + "<br/>");
            Response.Write("路径信息:" + Request.ServerVariables["PATH_INFO"] + "<br/>");
            Response.Write("URL的基本部分:" + Request.ServerVariables["url"] + "<br/>");

            //int loop1, loop2;
            //NameValueCollection coll;

            //// Load ServerVariable collection into NameValueCollection object.
            //coll = Request.ServerVariables;
            //// Get names of all keys into a string array.
            //String[] arr1 = coll.AllKeys;
            //Response.Write("arr1的长度为" + arr1.Length + "<br>");
            //for (loop1 = 0; loop1 < arr1.Length; loop1++)
            //{
            //    Response.Write("Key: " + arr1[loop1] + "<br>");
            //    String[] arr2 = coll.GetValues(arr1[loop1]);
            //    for (loop2 = 0; loop2 < arr2.Length; loop2++)
            //    {
            //        Response.Write("Value " + loop2 + ": " + Server.HtmlEncode(arr2[loop2]) + "<br>");
            //    }
            //}


            //获取客户端安全证书 ClientCertificate属性
            //Response.Write("安全证书:" + Request.ClientCertificate[关键字] + "<br/>");

            //获取当前请求的客户端安全证书。
            HttpClientCertificate cs = Request.ClientCertificate;

            Response.Write("ClientCertificate Settings:<br>");
            Response.Write("Certificate = " + cs.Certificate + "<br>");
            Response.Write("Cookie = " + cs.Cookie + "<br>");
            Response.Write("Flags = " + cs.Flags + "<br>");
            Response.Write("IsPresent = " + cs.IsPresent + "<br>");
            Response.Write("Issuer = " + cs.Issuer + "<br>");
            Response.Write("IsValid = " + cs.IsValid + "<br>");
            Response.Write("KeySize = " + cs.KeySize + "<br>");
            Response.Write("SecretKeySize = " + cs.SecretKeySize + "<br>");
            Response.Write("SerialNumber = " + cs.SerialNumber + "<br>");
            Response.Write("ServerIssuer = " + cs.ServerIssuer + "<br>");
            Response.Write("ServerSubject = " + cs.ServerSubject + "<br>");
            Response.Write("Subject = " + cs.Subject + "<br>");
            Response.Write("ValidFrom = " + cs.ValidFrom + "<br>");
            Response.Write("ValidUntil = " + cs.ValidUntil + "<br>");
            Response.Write("What's this = " + cs.ToString() + "<br>");

            //int loop3, loop4;
            //NameValueCollection coll2;

            //// Load ServerVariable collection into NameValueCollection object.
            //coll2 = Request.ClientCertificate;
            //// Get names of all keys into a string array.
            //String[] arr3 = coll2.AllKeys;
            //Response.Write("arr3的长度为" + arr3.Length  + "<br>");
            //for (loop3 = 0; loop3 < arr3.Length; loop3++)
            //{
            //    Response.Write("Key: " + arr3[loop3] + "<br>");
            //    String[] arr4 = coll2.GetValues(arr3[loop3]);
            //    for (loop4 = 0; loop4 < arr4.Length; loop4++)
            //    {
            //        Response.Write("Value " + loop4 + ": " + Server.HtmlEncode(arr4[loop4]) + "<br>");
            //    }
            //}


            Label2.Text = "您当前的IP为:" + IpLocation(IPAddress)[0];
            Label3.Text = "该IP所在地为:" + IpLocation(IPAddress)[1];
        }