开发者

Fetch IP Address

开发者 https://www.devze.com 2023-01-30 05:09 出处:网络
I want to get ip address of client machine Like I opened website on my machine which is ho开发者_JAVA百科sted on any server So i need IP address of my machine not hosted server IP.HttpContext.Current.

I want to get ip address of client machine Like I opened website on my machine which is ho开发者_JAVA百科sted on any server So i need IP address of my machine not hosted server IP.


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

use above syntax in C# otherwise you will get error like
Non-invocable member 'System.Web.HttpRequest.ServerVariables' cannot be used like a method.


    ''# VB
    HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")
    // C#
    HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]

This will get the PUBLIC ip address of the client computer. It will NOT get the LAN IP (192.168...)

0

精彩评论

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

关注公众号