Click here to Skip to main content
15,899,025 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
=Request.ServerVariables("REMOTE_ADDR")

Sir/Madam

I use this command in my website.But Always it gives 127.0.0.1
But my ip is like 128.125.158.192
then how can i do this.

Help me regarding this scenario
Posted
Comments
Sergey Alexandrovich Kryukov 16-Jan-13 23:31pm    
This IP just means localhost...
—SA
Nandakishore G N 16-Jan-13 23:39pm    
just host it and check..it will come..
ankur789 17-Jan-13 1:19am    
sir is it possible to fetch the ip without hosting
Nandakishore G N 17-Jan-13 5:51am    
answer will be the same...what you got earlier..The network which is connected gives a static global address of localhost...i.e, 127.0.0.1.
If you host the website, when an user opens the page in his system his ip will be tracked.And one more point is that IP will be always a floating address it is not static.
For More Info refer here
http://www.tech-faq.com/127-0-0-1.html

1 solution

check with this code, it may helps u.

C#
private string GetUserIP()
    {
        string ipList = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        if (!string.IsNullOrEmpty(ipList))
        {
            return ipList.Split(',')[0];
        }

        return Request.ServerVariables["REMOTE_ADDR"];
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900