I tried the following approach:
using System;
using System.Web;
public partial class WhatsMyIP : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
tbIPs.Text += "HttpContext.Current.Request.UserHostAddress:" + Environment.NewLine +
HttpContext.Current.Request.UserHostAddress + Environment.NewLine + Environment.NewLine;
tbIPs.Text += "HttpContext.Current.Request.ServerVariables['REMOTE_ADDR']:" + Environment.NewLine + HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] + Environment.NewLine;
tbIPs.Text += "System.Net.Dns.GetHostName():" + Environment.NewLine + System.Net.Dns.GetHostName() + Environment.NewLine;
tbIPs.Text += "System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()).GetValue(0).ToString():" +
Environment.NewLine +
System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()).GetValue(0).ToString() + Environment.NewLine;
}
}
but it seems to failed, when test it on actual server which is under an ISA/Firewall.
I have gone thru couple of forums such as:
Possible solution, BUT we need to use Active X (which is not a good approach).
Source: http://forums.asp.net/p/1276422/2432905.aspx#2432905
Q: How can I use JS to detect client IP?
A: You can get the actual IP by JavaScript, with the help of an ActiveX control, but the presents possibilities is low, because many browsers avoid ActiveX control and plug-in. see the source link for more details.
Possible solution:
See : http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21509072.html
Q: Retrieving a clients IP address
A: EugeneK-biruza: Anyway, reconfiguring the firewall to force it pass original address in additional headers will be the 100% working solution.
Can someone point me on how to "reconfiguring the firewall to force it pass original address in additional headers" , where using ISA as firewall.
Thanks in advanced.