In this article I am going to explain how to get the public IP address of visitors
In the previous post I have explained how to merge two or more datatables in c#using C# and vb.net and how to create image gallery in asp.net.
Many times we needed the IP address of visitors. To get the IP address of visitors use the below given snippets.
protected void Page_Load(object sender, EventArgs e)
ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipaddress == "" || ipaddress == null)
ipaddress = Request.ServerVariables["REMOTE_ADDR"];
lblipaddress.Text = ipaddress;
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim ipaddress As String
ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ipaddress = "" OrElse ipaddress Is Nothing Then
ipaddress = Request.ServerVariables("REMOTE_ADDR")
lblipaddress.Text = ipaddress
Build and run the application. To test it uploads it to server.
In this article we have learn how to get the public IP address of visitors. I hope you enjoyed this article. Please post you comment, query and feedback about this article. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.
What do you think about this article?
If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.