Get User's IP Address

后端 未结 5 1699
半阙折子戏
半阙折子戏 2020-12-05 10:39

How can I get the current visitors IP address?

5条回答
  •  误落风尘
    2020-12-05 11:20

    HttpContext.Current.Request.UserHostAddress;

    or

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

    or

    HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

提交回复
热议问题