Using the bellow code .
protected string GetUserIP()
{
string strUserIP = string.Empty;
if (HttpContext.Current.Request.ServerVariables[\"HTTP_X_FORW
Method that gets IP address: ASP.NET, C#
using System;
using System.Web;
namespace WebApplication1
{
public class Global : HttpApplication
{
protected void Application_BeginRequest(object sender, EventArgs e)
{
// Get request.
HttpRequest request = base.Request;
// Get UserHostAddress property.
string address = request.UserHostAddress;
// Write to response.
base.Response.Write(address);
// Done.
base.CompleteRequest();
}
}
}