In this post we will show you how to get IP Address of the Visitor in C#. The below code snippet will help you to get the Visitor IP address...
Code :
string GetVisitorIpAddress()
{
System.Web.HttpContext context = System.Web.HttpContext.Current;
string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if(!string.IsNullOrEmpty(ipAddress))
{
string[] ipAddresses = ipAddress.Split(',');
if(ipAddresses.Length != 0)
{
return ipAddresses[0];
}
}
return context.Request.ServerVariables["REMOTE_ADDR"];
}
Please Like and Share the Blog, if you find it interesting and helpful.
Code :
string GetVisitorIpAddress()
{
System.Web.HttpContext context = System.Web.HttpContext.Current;
string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if(!string.IsNullOrEmpty(ipAddress))
{
string[] ipAddresses = ipAddress.Split(',');
if(ipAddresses.Length != 0)
{
return ipAddresses[0];
}
}
return context.Request.ServerVariables["REMOTE_ADDR"];
}
Please Like and Share the Blog, if you find it interesting and helpful.
Related articles
- Integrate Colorbox in Asp Net Web Application
- How to Integrate CKEditor in Asp Net Web Application
- Using UNC path for Storing and Retrieving Files in ASP Net
- Asp Net Interview Questions and Answers - Part 1
- HTTP Error 500.22 - Internal Server Error
- Asp.Net : How to regenerate .designer.cs file for aspx or ascx files
- Run .sql script file in C#
- How to improve Asp.Net Application Performance - Part 2
- How to improve Asp.Net Application Performance - Part 1
- Globals in Nodejs
Ohayo,
ReplyDeleteAllow me to show my gratitude bloggers. You guys are like unicorns. Never seen but always spreading magic. Your content is yummy. So satisfied. ASP .Net
I want to create a Splitter with a left and a right pane. The right pane should have a fixed size, the left pane should have the rest size of the container div (which has 100% of the width). Unfortunately I can't find an exact documentation how the PaneSize works. The API description for PaneSize Property is "specifies the panesize", this is not very helpful. Can you please give me more information or provide a simple sample.
Follow my new blog if you interested in just tag along me in any social media platforms!
Thank you,
Radhey