How to Get IPAddress when User open web site using IP Address?

I am generating run time <a> link. To complete link I am using bellow code:

string appPath = protocol + System.Web.HttpContext.Current.Request.ServerVariables["HTTP_HOST"] + System.Web.HttpContext.Current.Request.ApplicationPath;.

But when user try to open web site from: at this time my link is created with

I want the address what ever user enter.

If user Open open website from the link should be

and If User open website from the link should be


Use REMOTE_ADDR server variable

string appPath = protocol + 
System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] + 

One of HTTP_HOST or SERVER_NAME should provide you with information on what user typed to get to your site. It may be good idea to check with Http debugger what browser actually sends in case of IP address to make sure you check correct values.


Use this function to get the IPAddress of the user. But there is a possibility that you may not get the actual IP. There are many concern like firewall etc. Which may expose same ip for all the computer on the network.

    public static string GetMachineName(HttpRequest moRequest)
        return moRequest.ServerVariables["HTTP_X_FORWARDED_FOR"] != null ||
               moRequest.ServerVariables["HTTP_CLIENT_IP"] != null
                   ? moRequest.ServerVariables["HTTP_X_FORWARDED_FOR"]
                   : moRequest.ServerVariables["REMOTE_ADDR"];

Need Your Help

Apache Solr on Appfog

java apache solr appfog

I am very new to Apache Solr and I am trying to deploy it on Appfog application running the Java runtime. I can deploy the start page:, but nothing else will work. Could someone

ExtJS4 dataView - Select node id

ajax extjs extjs4 extjs4.2 extjs-mvc

I have an ExtJS 4 dataView and i would like to catch the id of a selected node.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.