How to get the server IP Address?

后端 未结 4 1657
粉色の甜心
粉色の甜心 2020-12-29 03:32

Is there a 1 line method to get the IP Address of the server?

Thanks

4条回答
  •  不知归路
    2020-12-29 04:13

    Request.ServerVariables["LOCAL_ADDR"];
    

    From the docs:

    Returns the server address on which the request came in. This is important on computers where there can be multiple IP addresses bound to the computer, and you want to find out which address the request used.

    This is distinct from the Remote addresses which relate to the client machine.

提交回复
热议问题