How to get a user's client IP address in ASP.NET?

前端 未结 19 2603
时光取名叫无心
时光取名叫无心 2020-11-22 00:26

We have Request.UserHostAddress to get the IP address in ASP.NET, but this is usually the user\'s ISP\'s IP address, not exactly the user\'s machine IP address

19条回答
  •  青春惊慌失措
    2020-11-22 01:01

    Hello guys Most of the codes you will find will return you server ip address not client ip address .however this code returns correct client ip address.Give it a try. For More info just check this

    https://www.youtube.com/watch?v=Nkf37DsxYjI

    for getting your local ip address using javascript you can use put this code inside your script tag

    
    
    

    and For getting your public ip address you can use put this code inside your script tag

      function getIP(json) {
        document.write("My public IP address is: ", json.ip);
      }
    
    
    
    

提交回复
热议问题