ASP.NET 获取客户端访问端口

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{

    private void Page_Load(object sender, System.EventArgs e)
    {
        System.Collections.Specialized.NameValueCollection coll = Request.ServerVariables;

        foreach (string key in coll.AllKeys)
        {
            foreach (string value in coll.GetValues(key))
            {
                Response.Write(key + "------" + value + "<br/>");
            }
        }


        string port = Request.ServerVariables["REMOTE_PORT"].ToString();
        Response.Write(port);



    }


}

 

posted @ 2013-05-28 14:14  大笑江湖  阅读(1228)  评论(0编辑  收藏  举报