开发者

Same code or not for UserHostAddress?

开发者 https://www.devze.com 2023-04-12 19:33 出处:网络
Are the two methods below identical? HttpContext.Cur开发者_如何学Gorent.Request.UserHostAddress and

Are the two methods below identical?

HttpContext.Cur开发者_如何学Gorent.Request.UserHostAddress

and

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


Seems so. According to ILSpy the

HttpContext.Current.Request.UserHostAddress

maps to

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

So in my opinion, it is the same.

0

精彩评论

暂无评论...
验证码 换一张
取 消