ASP.NET CONFIG怎么得到网页访问的IP和URL

来源:百度知道 编辑:UC知道 时间:2024/06/24 11:14:45
ASP.NET CONFIG怎么得到网页访问的IP和URL,在线等,谢谢。

string ip = "";
if (Context.Request.ServerVariables["HTTP_VIA"] != null)
{
ip = Context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
ip = Context.Request.ServerVariables["REMOTE_ADDR"].ToString();
}

获取完整URL是
Request.Url.AbsoluteUrl

config? JSP里的吧。asp.net里没有。

要获取IP和URL很简单,只要使用下面的语句获取HttpRequest对象就可以都得到了

HttpRequest request = HttpContext.Current.Request;