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); } }