UserHostAddress的代码是否相同

本文关键字:是否 代码 UserHostAddress | 更新日期: 2023-09-27 18:11:18

下面的两个方法是相同的吗?

HttpContext.Current.Request.UserHostAddress

HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]

UserHostAddress的代码是否相同

似乎是这样。根据ILSpy

HttpContext.Current.Request.UserHostAddress

映射到

// System.Web.Hosting.ISAPIWorkerRequest
public override string GetRemoteAddress()
{
    return this.GetServerVariable("REMOTE_ADDR");
}

所以在我看来,这是一样的

相关文章: