cannot get ip address on a virtual machine

Posted by user175084 on Stack Overflow See other posts from Stack Overflow or by user175084
Published on 2010-06-03T14:57:46Z Indexed on 2010/06/03 15:04 UTC
Read the original article Hit count: 395

Filed under:
|
|
|

so i have a code which gets me the ip address of a machine i am wroking on.

so if my gui is published on the server and i access it from my local machine it gives me tha address of my local machine and when i access the gui from the server itself it gives me the server address.. which is fine.

But when i put the gui on a VM server and run it from a VM server itself i dont get the ip address. this works fine if i access it from another machine but does not work only when accesing gui on VM server..

please help me out as i get this value ":::1"

here is my code:

        string ipaddress;
        //string ipaddress = Request.ServerVariables["LOCAL_ADDR"];
        string ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        if (ipaddress == "" || ipaddress == null)
        string ipaddress = Request.ServerVariables["REMOTE_ADDR"];
        Label5.Text = ipaddress;

thank you

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET